简体   繁体   中英

date time in javascript 24 hours format

var date = "8-21-2012";
var time = "00:00";
var dateArr = new Array();

dateArr = date.split("-");
var timeArr = new Array();
timeArr = time.split(":");


var date1 = "8-21-2012";
var time1 = "20:00";
var dateArr1 = new Array();

dateArr1 = date1.split("-");
var timeArr1 = new Array();
timeArr1 = time1.split(":");

var birthday = new Date(parseInt(dateArr[2], 10), parseInt(dateArr[0], 10), parseInt(dateArr[1], 10), parseInt(timeArr[0], 10), parseInt(timeArr[1], 10), parseInt(00, 10));

var birthday1 = new Date(parseInt(dateArr1[2], 10), parseInt(dateArr1[0], 10), parseInt(dateArr1[1], 10), parseInt(timeArr1[0], 10), parseInt(timeArr1[1], 10), parseInt(00, 10));

Now in first time it's 00 means 24 hours Birthday object should be greater logically but it's showing birthday1 in greater. It's unable to compare this 00 time. Other than that everything is fine. Please help.

在同一日期,0000小于2000。如果要第二天开始,则需要更改日期。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM