Dates displaying in US format

S

Sheila Jones

Hello,

I have written a webpage that displays details of some files on the
webserver. It includes the following lines:
FileInfo fi = new FileInfo(file);
cell.Text = fi.CreationTime.ToString();

It works OK, except that the date is displayed in US format
(month/day/year), not UK format. The help file for DateTime.ToString says
"This method uses formatting information derived from the current culture".
So obviously, the 'current culture' is set incorrectly. Where and how do I
change this?

Thanks.
 
P

Patrice Scribe

If you need always the same formatting, you could change it using the
web.config file (see the Globalization entry in the documentation).

If you need to work with multiple culture you could also set it
programmatically using Page.Culture or by changing the culture on the
current thread....

Patrice
 
S

Sheila Jones

Hello Patrice,

Thank you for your reply. But why doesn't ASP.Net default to using the
machine's Regional Settings? That would seem more logical to me.
 
P

Patrice Scribe

Good point though this sometimes not easy (should the system default or the
account default used ?).
The nice thing with web.config is that you have control without regards to
server settings...

For now I'm unable to find where in the doc is specified what the default
cutlture should be...
(we have no problem here as we usually set it from the user profile).

Patrice

--
 

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

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top