Currently when using
System.DateTime.Now.TimeOfDay
It will display 4 decimals:
Hours:Minutes:Seconds:TT
How can I make it display only 3
Hours:Minutes:Seconds?
Like a normal clock?
Currently when using
System.DateTime.Now.TimeOfDay
It will display 4 decimals:
Hours:Minutes:Seconds:TT
How can I make it display only 3
Hours:Minutes:Seconds?
Like a normal clock?
Based on the documentation here DateTime Struct (System) | Microsoft Learn you need to use the ToString Method and pass the format you want.
System.DataTime.Now.ToString("h:mm");
You just split off the milliseconds. Try this:
string time = System.DateTime.Now.TimeOfDay.ToString().Split('.')[0];
Debug.Log(time);