Dates displaying in US format

  • Thread starter Thread starter Sheila Jones
  • Start date Start date
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.
 
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
 
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.
 
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

--
 
Back
Top