Tuesday, March 13, 2012

Setting time format to 24 hour (DK culture)

Hi

I would like my website to only use the 24h time format, but when i set som variables to a specifik time, they end up in PM/AM format. For example i have to declarations:

Dim mintid As DateTime = Convert.ToDateTime("12:15").ToShortTimeString
Dim maxtid As DateTime = Convert.ToDateTime("21:15").ToShortTimeString

And they end up to be: mintid= 12.15 PM, maxtid= 9.15 PM

Wich gives me the wrong result, now that maxtid is smaller than mintid..

Ive tried setting the Culture to danish in the Page settings, but that didnt do much

The 24hour format only comes into play when you are converting from a DateTime to a string. You can use capitol HH when you want hours in a 24 hour format.

Dim timeStringAs String =Date.Now.ToString("HH.mm")

0 comments:

Post a Comment