Regex to validate date format dd/mm/yyyy

后端 未结 21 2931
挽巷
挽巷 2020-11-21 06:32

I need to validate a date string for the format dd/mm/yyyy with a regular expresssion.

This regex validates dd/mm/yyyy, but not the invalid

21条回答
  •  耶瑟儿~
    2020-11-21 07:02

    I know it is a tangential answer to the question, but if the intention of the question is 'how do I validate a date?', then why not try letting the programming language do all the hard work (if you are using a language that can)?

    e.g. in php

    $this_date_object = date_create($this_date);
    
    if ($this_date_object == false )
        {
    
            // process the error
    
        }
    

提交回复
热议问题