Created
June 29, 2016 10:40
-
-
Save zoubin/cc6d3deb48bb73237168c13269aa3ae0 to your computer and use it in GitHub Desktop.
Check if a given date string specifies a valid date
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://jsbin.com/lamakud/edit?html,output | |
function isValidateDate(datestr) { | |
var ms = Date.parse(datestr) | |
if (isNaN(ms)) return false | |
return ~~(datestr.split(/[^d]/).pop()) === new Date(ms).getDate() | |
} | |
module.exports = isValidateDate |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment