300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > JS时间 时间戳 以及年月日时分秒格式时间的相互转化

JS时间 时间戳 以及年月日时分秒格式时间的相互转化

时间:2023-04-08 16:38:57

相关推荐

JS时间 时间戳 以及年月日时分秒格式时间的相互转化

1、时间

var time=new Date()

2、时间=>时间戳

var time=new Date().getTime()

3、时间戳=>时间

var time=new Date( new Date().getTime()+3600*1000*24* 10 ) //时间戳加一天

4、时间=>年月日时分秒

var val= new Date()

var formmatTime=val.getFullYear() + '-' + this.p((val.getMonth() + 1)) + '-' + this.p(val.getDate())+' '+this.p(val.getHours())+":"+this.p(val.getMinutes())+":"+this.p(val.getSeconds())

p(s) {

return s < 10 ? '0' + s : s

},

5、年月日时分秒=>时间

var time=new Date( “-05-13 14:34:44” )

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。