DateTime.ToShortTimeString

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)
 
N

Natty Gur

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,143
Latest member
DewittMill
Top