In .net, when I know the culture info, how do I know the time format of 12/24 hours? Is there an easy way to detect the culuter info specified time format?
What I need to know is just if the culture should use 12/24 hour time format. I know some cultures could use both 12/24 hour time format. But what's the default time format when we use DateTime.ToShortTimeString()? How do we know the default time format is 12 or 24?
One way would be to have a look at the format string:
If the format string contains
H
, it means it's using 24-hour. If it containsh
ortt
, though - it's 12-hour.This is more of a dirty hack than a proper solution, though (and I'm not sure it will work for all cultures - you might need to handle escaping). The question is - why are you even trying to determine the 12/24-hourness? Just use the proper format for the given culture and be done with it.