Date Format

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • SK

    #1

    Date Format

    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
  • Jon Skeet [C# MVP]

    #2
    Re: Date Format

    SK <anonymous@disc ussions.microso ft.com> wrote:[color=blue]
    > 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[/color]

    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 :(

    --
    Jon Skeet - <skeet@pobox.co m>
    Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

    If replying to the group, please do not mail me too

    Comment

    • Shiva

      #3
      Re: Date Format

      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.Curren tTimeZone.Stand ardName. Again, this doesn't give the
      abbriviated time zone code (like JST), but the full form.

      HTH

      "SK" <anonymous@disc ussions.microso ft.com> wrote in message
      news:115a01c47b 99$2ee32f70$a30 1280a@phx.gbl.. .
      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


      Comment

      • SK

        #4
        Re: Date Format

        Thanks..
        How to get the millisecond also.
        Is it possible to display the time as say GMT+ 5:30.
        Please help

        [color=blue]
        >-----Original Message-----
        >SK <anonymous@disc ussions.microso ft.com> wrote:[color=green]
        >> 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[/color][/color]
        individually[color=blue][color=green]
        >> and concatenate it. Is there any other way of doing it
        >> using CultureInfo class[/color]
        >
        >DateTime dt = ...;
        >
        >string formatted = dt.ToString ("yyyy/MM/dd HH:mm:ss")
        >
        >gets you the first bit. Unfortunately, TimeZones aren't[/color]
        very well[color=blue]
        >supported in .NET at the moment :(
        >
        >--
        >Jon Skeet - <skeet@pobox.co m>
        >http://www.pobox.com/~skeet
        >If replying to the group, please do not mail me too
        >.
        >[/color]

        Comment

        • Jon Skeet [C# MVP]

          #5
          Re: Date Format

          SK <anonymous@disc ussions.microso ft.com> wrote:[color=blue]
          > How to get the millisecond also.[/color]

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

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

          --
          Jon Skeet - <skeet@pobox.co m>
          Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

          If replying to the group, please do not mail me too

          Comment

          Working...