DateTime.ToShortTimeString

  • Thread starter Thread starter Doug Swanson
  • Start date Start date
D

Doug Swanson

I have some questions about datetime formatting....In our web app I have the
following in the web.config
<globalization
requestEncoding="utf-8"
responseEncoding="utf-8"
culture="en-US"
uiCulture="en-US"

Based on 3:00 pm time
Now whenever I use DateTime.toShortTimeString I get "3:00 P.M" but what I
really want is "15:00". Do I have to use DateTime.toString("HH:MM")? If I
"hard code" that in my app how will that affect things if my culture changes
to say German? (or is military time universal?) What other things should I
be doing to ensure that our app can be "globalized"?

thanks
Doug
--
Doug Swanson
Senior Applications Developer
Synchrono, Inc
651.228.1772
(e-mail address removed)
 
Hi,

1) Generally it's good practice to format your data and time to your
chosen format and not to relay on the machine settings. Remember that
any user / administrator can change formats.

2) If you will "hard code" date/time formats it want effects culture
settings:
string date = dt.ToString("D"); produce English string or Hebrew string
depends on culture settings.

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
 
Back
Top