var a=Date.now() //获取当前时间的13位时间戳
var b=Date() //获取当日的日期
//seconds 为秒数
second=parseInt(seconds % 60)
minute= parseInt(seconds / 60 % 60),
hour=parseInt(seconds / 60 / 60 % 24),
day= parseInt(seconds / 60 / 60 / 24)
var now=Date.now()
getFullDate(now)
function getFullDate(timestamp) {
//timestamp是十三位时间戳
var now=new Date(timestamp)
var obj = {}
obj.y = now.getYear() + 1900
obj.mon = now.getMonth() + 1
obj.d = now.getDate()
obj.h = now.getHours()
obj.m = now.getMinutes()
obj.s = now.getSeconds()
return obj
}
// y, mon, d, h, m, s 分别表示年,月,日,天,分,秒
function setDate(y, mon, d, h, m, s) {
if (!y&&y!=0) {
y = 0
}
if (!mon&&mon!=0) {
mon = 0
}
if (!d&&d!=0) {
d = 0
}
if (!h&&h!=0) {
h = 0
}
if (!m&&m!=0) {
m = 0
}
if (!s&&s!=0) {
s = 0
}
return new Date(y, mon, d, h, m, s).getTime()
}
网友评论