function GetNumberOfDays(date1
,date2
){
var a1
= Date
.parse(new Date(date1
));
var a2
= Date
.parse(new Date(date2
));
var day
= parseInt((a2
-a1
)/ (1000 * 60 * 60 * 24));
return day
};
var a1
="12-19-2018";
var a2
="2019/1/7";
var b
=GetNumberOfDays(a1
,a2
)
console
.log(b
);
-------------------------------------------------------------------------------------------------
function DateFormat(dateTime
){
var dateParse
= Date
.parse(new Date(dateTime
));
var time
= new Date(dateParse
);
var y
= String(time
.getFullYear());
var m
= String(time
.getMonth()+1);
var d
= String(time
.getDate());
var h
= String(time
.getHours());
var u
= String(time
.getMinutes());
var s
= String(time
.getSeconds());
return {y
,m
,d
,h
,u
,s
}
}
var a
="2017/12/31 23:12:54";
console
.log(DateFormat(a
));
从日期中获取星期
var weekDay
= ["星期天", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
var myDate
= new Date(Date
.parse("2018/5/19"));
console
.log(weekDay
[myDate
.getDay()]);
转载请注明原文地址:https://tech.qufami.com/read-5285.html