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 convertion

DateTime convertion

Scheduled Pinned Locked Moved C#
regex
5 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.
  • S Offline
    S Offline
    salmonraju
    wrote on last edited by
    #1

    Hi, I want to convert the below string to DateTime object . I am unable to do this using Convert.ToDateTime() Wed Feb 24 04:56:30 2010 Please suggest. Please provide regular expression if required. Thanks,

    OriginalGriffO M P 3 Replies Last reply
    0
    • S salmonraju

      Hi, I want to convert the below string to DateTime object . I am unable to do this using Convert.ToDateTime() Wed Feb 24 04:56:30 2010 Please suggest. Please provide regular expression if required. Thanks,

      OriginalGriffO Offline
      OriginalGriffO Offline
      OriginalGriff
      wrote on last edited by
      #2

      If it is always going to be in that format, then you could use String.Split to break it on the spaces, and then re-assemble for conversion, or use Convert.ToInt repeatedly in a DateTime constructor.

      You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy

      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
      "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

      1 Reply Last reply
      0
      • S salmonraju

        Hi, I want to convert the below string to DateTime object . I am unable to do this using Convert.ToDateTime() Wed Feb 24 04:56:30 2010 Please suggest. Please provide regular expression if required. Thanks,

        M Offline
        M Offline
        Mirko1980
        wrote on last edited by
        #3

        Look about DateTime.ParseExact and Custom DateTime format strings. You can parse your date using DateTime.ParseExact("Wed Feb 24 04:56:30 2010", "ddd MMM dd HH:mm:ss yyyy", System.Globalization.CultureInfo.InvariantCulture);

        S 1 Reply Last reply
        0
        • M Mirko1980

          Look about DateTime.ParseExact and Custom DateTime format strings. You can parse your date using DateTime.ParseExact("Wed Feb 24 04:56:30 2010", "ddd MMM dd HH:mm:ss yyyy", System.Globalization.CultureInfo.InvariantCulture);

          S Offline
          S Offline
          salmonraju
          wrote on last edited by
          #4

          Thank you it is working.

          1 Reply Last reply
          0
          • S salmonraju

            Hi, I want to convert the below string to DateTime object . I am unable to do this using Convert.ToDateTime() Wed Feb 24 04:56:30 2010 Please suggest. Please provide regular expression if required. Thanks,

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

            The Convert class is rarely the best way to do anything; avoid it.

            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