Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. DateTime Format

DateTime Format

Scheduled Pinned Locked Moved C#
question
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    eggie5
    wrote on last edited by
    #1

    How can I get DateTime.now in this format: "Wed, 05 Apr 2006 21:12:00 GMT" ?

    /\ |_ E X E GG

    J P 2 Replies Last reply
    0
    • E eggie5

      How can I get DateTime.now in this format: "Wed, 05 Apr 2006 21:12:00 GMT" ?

      /\ |_ E X E GG

      J Offline
      J Offline
      JoeRip
      wrote on last edited by
      #2

      You use the .ToString() method of your variable, and you pass it a DateTimeFormatInfo argument, described here: http://msdn2.microsoft.com/en-us/library/system.globalization.datetimeformatinfo(VS.71).aspx[^]

      J 1 Reply Last reply
      0
      • J JoeRip

        You use the .ToString() method of your variable, and you pass it a DateTimeFormatInfo argument, described here: http://msdn2.microsoft.com/en-us/library/system.globalization.datetimeformatinfo(VS.71).aspx[^]

        J Offline
        J Offline
        JoeRip
        wrote on last edited by
        #3

        For instance, you can use: string const MY_LONG_FORMAT = "MM/dd/yy HH:mm:ss:ffff" string output = DateTime.Now(MY_LONG_FORMAT); Note that the above format is NOT the one you want; you'll need to look at the link I provided in the earlier post to see how to build your format string.

        modified on Friday, December 28, 2007 3:48:36 AM

        X 1 Reply Last reply
        0
        • J JoeRip

          For instance, you can use: string const MY_LONG_FORMAT = "MM/dd/yy HH:mm:ss:ffff" string output = DateTime.Now(MY_LONG_FORMAT); Note that the above format is NOT the one you want; you'll need to look at the link I provided in the earlier post to see how to build your format string.

          modified on Friday, December 28, 2007 3:48:36 AM

          X Offline
          X Offline
          Xmen Real
          wrote on last edited by
          #4

          string output = DateTime.Now.ToString("MM/dd/yy HH:mm:ss:ffff");

          it will also work

          Becoming Programmer...

          1 Reply Last reply
          0
          • E eggie5

            How can I get DateTime.now in this format: "Wed, 05 Apr 2006 21:12:00 GMT" ?

            /\ |_ E X E GG

            P Offline
            P Offline
            PIEBALDconsult
            wrote on last edited by
            #5

            Please only use ISO 8601 compliant formats.

            E 1 Reply Last reply
            0
            • P PIEBALDconsult

              Please only use ISO 8601 compliant formats.

              E Offline
              E Offline
              eggie5
              wrote on last edited by
              #6

              ok

              /\ |_ E X E GG

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups