problem formating datetime

J

Jeff

hi

..NET 3.5

I have a variable of type datatime which I want to format before it's
displayed on a webpage.

here is how I did it:
DateTimeFormatInfo format = new DateTimeFormatInfo();
literal.Text = comment.RegDate.ToString("dd.MM.yyyy HH:mm",format);

but I doubt this is a good approach. Cause for some viewers dd.MM.yyyy is
not the correct format. I want the datatime to be displayed as the user
wants datetime to be displayed... some countries have day first, and some
have month first... So I cannot hardcode as I just did there.

any suggestions?
 
A

Anthony Jones

Jeff said:
hi

.NET 3.5

I have a variable of type datatime which I want to format before it's
displayed on a webpage.

here is how I did it:
DateTimeFormatInfo format = new DateTimeFormatInfo();
literal.Text = comment.RegDate.ToString("dd.MM.yyyy HH:mm",format);

but I doubt this is a good approach. Cause for some viewers dd.MM.yyyy is
not the correct format. I want the datatime to be displayed as the user
wants datetime to be displayed... some countries have day first, and some
have month first... So I cannot hardcode as I just did there.

any suggestions?

Have a read through this article:-

http://msdn.microsoft.com/en-us/library/bz9tc508.aspx
 

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

Top