最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

将字符串转换为nodejs中的ISO日期时间

运维笔记admin11浏览0评论

将字符串转换为nodejs中的ISO日期时间

将字符串转换为nodejs中的ISO日期时间

将此日期转换为nodejs中的ISO格式

     created_at="September 17th 2019, 16:50:17.000";  
     let new_time = new Date(created_at);
     created_at = new_time.toISOString();
     console.log(created_at);

输出:无效日期

确切的输出是ISO格式。像这样的2011-10-05T14:48:00.000Z

回答如下:

您必须以以下格式传递日期字符串,才能将其转换为ISO日期:

var date 1 = "September 17 2019, 16:50:17.000";
let new_date = new Date(date1);
console.lof(new_date);
console.log(new_date.toISOString());
发布评论

评论列表(0)

  1. 暂无评论