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. Web Development
  3. Validating a Date!

Validating a Date!

Scheduled Pinned Locked Moved Web Development
regexquestion
4 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.
  • M Offline
    M Offline
    MarcusCole6833
    wrote on last edited by
    #1

    Is it better to split a string with clear instructions or use Regex with Clear Instructions?

    W Richard DeemingR E 3 Replies Last reply
    0
    • M MarcusCole6833

      Is it better to split a string with clear instructions or use Regex with Clear Instructions?

      W Offline
      W Offline
      Wendelius
      wrote on last edited by
      #2

      Why not simply use DateTime.TryParse[^]?

      1 Reply Last reply
      0
      • M MarcusCole6833

        Is it better to split a string with clear instructions or use Regex with Clear Instructions?

        Richard DeemingR Offline
        Richard DeemingR Offline
        Richard Deeming
        wrote on last edited by
        #3

        On the client side, Moment.js[^] or one of the many javascript date pickers would be the best option. On the server side, it depends which framework / language you're using. For .NET, DateTime.TryParse is the way to go, as Mika suggested. Other frameworks will probably have something very similar. If you try to re-invent date validation using string manipulation, you'll either get it wrong, or drive yourself mad trying. :)


        "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

        "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

        1 Reply Last reply
        0
        • M MarcusCole6833

          Is it better to split a string with clear instructions or use Regex with Clear Instructions?

          E Offline
          E Offline
          Erick Shawn
          wrote on last edited by
          #4

          Hi Marcus, Follow this code to parse date and time. http://www.dotnetperls.com/datetime-parse[^]

          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