strtotime()
/**
* 日付文字列を時刻値 (ミリ秒)に変換
*
* @param {string} d
* @return {number}
*/
function strtotime( d ) {
return new Date( d ).getTime();
}
使ってみる
let timeA = strtotime( "Tue Aug 08 2017 00:00:00 GMT+0900 (JST)" );
let timeB = strtotime( "Wed Aug 09 2017 00:00:00 GMT+0900 (JST)" );
console.log( timeA );
console.log( timeB );
console.log( typeof timeA );
if ( timeA > timeB )
console.log( 'timeA is latest.' );
else
console.log( 'timeB is latest.' );
/*
1502118000000
1502204400000
number
timeB is latest.
*/