problem formating datetime

  • Thread starter Thread starter Jeff
  • Start date Start date
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?
 
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
 
Back
Top