我有一个日期存储在如下变量中
var date = moment(new Date()).valueOf();
我需要像下面这样格式化
CCYY-MM-DDThh:mm:ss[.sss]TZD
The Time Zone Definition is mandatory and MUST be either UTC (denoted by addition of the character 'Z' to the end of the string) or some offset from UTC (denoted by addition of '[+|-]' and 'hh:mm' to the end of the string).
我试过如下
var required = moment.utc(date).format('CCYY-MM-DDThh:mm:ss[.sss]TZD')
但是结果如下
"CC14-06-03T07:59:15.sssT+00:003"
但预期的格式示例是
UTC :
1969-07-21T02:56:15Z
Houston time :
1969-07-20T21:56:15-05:00
最佳答案
关于javascript - 将日期转换为指定格式 moment.js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24010112/