RFC3339时间格式与普通时间格式,相互转换函数封装
export const rfctodate = (date) => {
const date1 = new date(date).tojson();
const newdate = new date(+new date(date1) + 8 * 3600 * 1000)
.toisostring()
.replace(/t/g, ' ')
.replace(/\.[\d]{3}z/, '');
return newdate;
};
export const datetorfc = (date) => {
const y = new date(date).getfullyear();
const m =
new date(date).getmonth() + 1 < 10
? `0${new date(date).getmonth() + 1}`
: new date().getmonth() + 1;
const d =
new date(date).getdate() < 10
? `0${new date(date).getdate()}`
: new date(date).getdate();
const hh =
new date(date).gethours() < 10
? `0${new date(date).gethours()}`
: new date(date).gethours();
const mm =
new date(date).getminutes() < 10
? `0${new date(date).getminutes()}`
: new date(date).getminutes();
const ss =
new date(date).getseconds() < 10
? `0${new date(date).getseconds()}`
: new date(date).getseconds();
let enddate = `${y}-${m}-${d} ${hh}:${mm}:${ss}`;
enddate = `${enddate.replace(/\s+/g, 't')}+08:00`;
return enddate;
};
相关文章:
-
-
-
这样,等真的沉下心来学习,不至于被找资料分散了心神。另外,给大家安排了一波学习面试资料:以上就是本文的全部内容,希望对大家的面试有所帮助,祝大家早日升职加薪迎娶白富美走上人生巅峰!…
-
-
-
版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。
如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。
发表评论