如何将ISO日期和时间格式转换为“ DD Mon YYYY hh:mm:ss”? [英] How to convert ISO date and time format to "DD Mon YYYY hh:mm:ss"?

查看:253
本文介绍了如何将ISO日期和时间格式转换为“ DD Mon YYYY hh:mm:ss”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个这样的变量

var date = "2016-04-07T03:03:03Z";

如何将其转换为这样的时间格式 2016年4月6日,

How do I convert it to a time format like this 6 Apr 2016, 8:03:03 PMin the local timezone using JavaScript/jQuery?

推荐答案

在8:03:03 PM 在本地时区使用JavaScript / jQuery?

As you want to parse it with a timezone and then format the output, I'd strongly suggest using Moment.js which is a well used library for time and date manipulation:

代码看起来像这样:

var date = "2016-04-07T03:03:03Z";
console.log(moment(date).format('D MMM YYYY, h:mm:ss A')); 
// "7 Apr 2016, 5:03:03 AM"

这篇关于如何将ISO日期和时间格式转换为“ DD Mon YYYY hh:mm:ss”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆