js判斷時間

weixin_34214500發表於2018-06-03

var date =new Date();

$("#lastTask-dateTime").val(date.getFullYear() +'-' +formatDate(date.getMonth() +1) +'-' +formatDate(date.getDate()) +' 00:00:00');

function formatDate(num) {

return num >9 ? num :'0' + num;

}


var now =new Date();

str =$("#lastTask-dateTime").val();

var d =new Date(str);

if (now.getFullYear() == d.getFullYear() && now.getMonth() == d.getMonth() && now.getDate() == d.getDate()) {

相關文章