date conversion

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

    #1

    date conversion

    Hi,

    How do i convert this "Sun Jun 29 00:00:00 UTC 0800 2003"
    to the normal date format (mm/dd/yyyy).

    Thanks
    Reb
  • Jon Skeet

    #2
    Re: date conversion

    Reb <gbreb@yahoo.co m> wrote:[color=blue]
    > How do i convert this "Sun Jun 29 00:00:00 UTC 0800 2003"
    > to the normal date format (mm/dd/yyyy).[/color]

    Use DateTime.Parse and one of the DateTime.ToStri ng variants.

    Look up "Date and Time Format Strings" in the MSDN 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

    • reb

      #3
      Re: date conversion

      hi Jon,

      I tried to do this method. But looks like, it couldn't
      recognise the format.

      CultureInfo en = new CultureInfo("en-US");
      String format = "MM/dd/yyyy hh:mm:sszzz";

      // Converts the string back to a local DateTime and
      displays it.
      DateTime parsedBack =
      DateTime.ParseE xact(day,format ,en.DateTimeFor mat);

      have u come across this before?
      thx
      Reb
      [color=blue]
      >-----Original Message-----
      >Reb <gbreb@yahoo.co m> wrote:[color=green]
      >> How do i convert this "Sun Jun 29 00:00:00 UTC 0800[/color][/color]
      2003"[color=blue][color=green]
      >> to the normal date format (mm/dd/yyyy).[/color]
      >
      >Use DateTime.Parse and one of the DateTime.ToStri ng[/color]
      variants.[color=blue]
      >
      >Look up "Date and Time Format Strings" in the MSDN for[/color]
      more[color=blue]
      >information.
      >
      >--
      >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

        #4
        Re: date conversion

        reb <gbreb@yahoo.co m> wrote:[color=blue]
        > I tried to do this method. But looks like, it couldn't
        > recognise the format.
        >
        > CultureInfo en = new CultureInfo("en-US");
        > String format = "MM/dd/yyyy hh:mm:sszzz";
        >
        > // Converts the string back to a local DateTime and
        > displays it.
        > DateTime parsedBack =
        > DateTime.ParseE xact(day,format ,en.DateTimeFor mat);
        >
        > have u come across this before?[/color]

        Well, if you're trying to convert *from*
        "Sun Jun 29 00:00:00 UTC 0800 2003" then the pattern you gave above
        certainly won't work - you need to parse with one pattern and then
        format with another.

        --
        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...