Date Format

  • Thread starter Thread starter SK
  • Start date Start date
S

SK

I want my date to be displayed like this.
2003/08/04 15:08:12 JST
How to do it.?. I dont want to get each item individually
and concatenate it. Is there any other way of doing it
using CultureInfo class
 
SK said:
I want my date to be displayed like this.
2003/08/04 15:08:12 JST
How to do it.?. I dont want to get each item individually
and concatenate it. Is there any other way of doing it
using CultureInfo class

DateTime dt = ...;

string formatted = dt.ToString ("yyyy/MM/dd HH:mm:ss")

gets you the first bit. Unfortunately, TimeZones aren't very well
supported in .NET at the moment :(
 
This custom format will get the date format you are looking for (without
timezone): "yyyy/MM/dd HH:mm:ss"

If you want the current time zone to be shown, append
TimeZone.CurrentTimeZone.StandardName. Again, this doesn't give the
abbriviated time zone code (like JST), but the full form.

HTH

I want my date to be displayed like this.
2003/08/04 15:08:12 JST
How to do it.?. I dont want to get each item individually
and concatenate it. Is there any other way of doing it
using CultureInfo class
 
Thanks..
How to get the millisecond also.
Is it possible to display the time as say GMT+ 5:30.
Please help
 
SK said:
How to get the millisecond also.

Read the docs on custom data and time formats - you need ".fff" to get
milliseconds.
Is it possible to display the time as say GMT+ 5:30.

I think so, but only if it's from the system timezone. Again, see the
docs for more information.
 
Back
Top