Regular Expression to validate a timestamp

后端 未结 13 559
名媛妹妹
名媛妹妹 2021-01-01 01:19

I need a regular expression to validate a timestamp of the format, using Javascript:

YYYY/MM/DD HH:MI:SS

I trie

13条回答
  •  伪装坚强ぢ
    2021-01-01 02:00

    function isTimestamp($input){
                var $regex = /^\d\d\d\d-(0?[1-9]|1[0-2])-(0?[1-9]|[12][0-9]|3[01]) (00|[0-9]|1[0-9]|2[0-3]):([0-9]|[0-5][0-9]):([0-9]|[0-5][0-9])$/;
                return $regex.test($input);
            }
    

    check please

提交回复
热议问题