900字范文,内容丰富有趣,生活中的好帮手!
900字范文 > 中国标准时间 标准时间 时间戳时间格式转换

中国标准时间 标准时间 时间戳时间格式转换

时间:2020-09-07 11:35:26

相关推荐

中国标准时间 标准时间 时间戳时间格式转换

中国标准时间-格式: Sat Apr 09 08:00:00 GMT+0800 (中国标准时间)

标准时间-格式: -04-09

时间戳-格式: 1649462400000

一、中国标准时间和标准时间相互转换

1、中国标准时间 => 标准时间

// 中国标准时间 转换成 年月日function getSimpleDate(date) {var y = date.getFullYear();var m = date.getMonth() + 1;m = m < 10 ? ('0' + m) : m;var d = date.getDate();d = d < 10 ? ('0' + d) : d;var h = date.getHours();var minute = date.getMinutes();minute = minute < 10 ? ('0' + minute) : minute;var s = date.getSeconds();s = s < 10 ? '0' + s : s;return y + '-' + m + '-' + d + ' ' + h + ':' + minute + ':' + s;}

2、标准时间 => 中国标准时间

var s=new Date(stime).getTime();

二、中国标准时间和时间戳相互转换

1、中国标准时间 => 时间戳

new Date() // Wed Jan 12 11:14:50 GMT+0800 (中国标准时间)new Date().getTime() // 1641957294080

2、时间戳 => 中国标准时间

function getSimpleDate(date) {let dd = new Date(date) // 时间戳转化成中国标准时间格式return dd }

三、标准时间 和 时间戳 相互转换

1、标准时间 => 时间戳

function getSimpleDate(date) {let stamp = new Date(currentDate).getTime() // 年月日转化成时间戳//let preDate = new Date(currentDate).getTime() - (24 * 60 * 60 * 1000) // 前一天时间戳//let afterDate = new Date(currentDate).getTime() + (24 * 60 * 60 * 1000) // 后一天时间戳return stamp}

2、时间戳 => 标准时间

function getSimpleDate(date) {let dd = new Date(date).getTime() // 时间戳转化成标准时间return dd }

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