Hi, I need to create a textfield to make player input their birthday, but we need them to input formatted date, like 20100618, how can this be done?
Thx
Firstly, you should check that String.Length returns a value of 8 for the date string. Then, you can extract substrings using the .NET library’s Substring function:-
var year = System.String.Substring(dateStr, 0, 4);
var month = System.String.Substring(dateStr, 4, 2);
var day = System.String.Substring(dateStr, 6, 2);
You can also use System.Int32.Parse if you need to convert the date components to integer:-
var yearNum = System.Int32.Parse(year);