I need a regular expression to validate a timestamp of the format, using Javascript:
YYYY/MM/DD HH:MI:SS
I trie
function validateTimestamp(timestamp) {
if (!/\d{4}\/\d{2}\/\d{2} \d{2}:\d{2}:\d{2}/.test(timestamp)) {
return false;
}
var split = timestamp.split(/[^\d]+/);
var year = parseFloat(split[0]);
var month = parseFloat(split[1]);
var day = parseFloat(split[2]);
var hour = parseFloat(split[3]);
var minute = parseFloat(split[4]);
var second = parseFloat(split[5]);
return hour < 25 && minute < 61 && second < 61 && month < 13 && day < 32;
}