- Home /
Which time format is set on a (mobile) device?
Hi everyone, couldn't find an answer to my question anywhere. I am showing a digital clock in my game and want it to to either use the 24hrs format or the am/pm format depending on the users setting on his device. Is there any possibility to find this out?
Answer by Bunny83 · Sep 18, 2015 at 11:35 AM
There usually isn't something like a bool flag which indicates 12h or 24h. There are time format strings from which you can determine if a time in the current culture should be formatted as 12h or 24h.
See this SO question.
There might be a native interface which might allow you to determine which kind is used / set in the system, but that would depend on the target OS (iOS, Android, WindowsPhone, Blackberry, ...) and would require some sort of native plugin.
If you just want to convert a DateTime value to a string, the ToString method usually uses the local culture settings. So as long as you don't provide a custom format string you'll get a string in the OS preferred setting.
You should lookup CultureInfo and DateTimeFormat. To get your software to run bug-free on all systems there's a long way to go ^^.
Thanks for the reply.
Thats what i feared :(. I will mark your answer as accepted.
Your answer
![](https://koobas.hobune.stream/wayback/20220612033848im_/https://answers.unity.com/themes/thub/images/avi.jpg)