如何将毫秒转换为可读日期? [英] How to convert milliseconds into a readable date?
本文介绍了如何将毫秒转换为可读日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下内容:
new Date(1324339200000).toUTCString()
输出:
"Tue, 20 Dec 2011 00:00:00 GMT"
我需要它返回 12月20日
。除了 toUTCString()
之外,我还能使用更好的方法吗?我正在寻找任何解析毫秒的方法,以返回一个人类可读的日期。
I need it to return Dec 20
. Is there a better method I can use besides toUTCString()
? I am looking for any way to parse through milliseconds, to return a human readable date.
推荐答案
使用你可以完成的库Datejs这非常优雅,其 toString
格式说明者: http://jsfiddle.net/TeRnM/1/ 。
Using the library Datejs you can accomplish this quite elegantly, with its toString
format specifiers: http://jsfiddle.net/TeRnM/1/.
var date = new Date(1324339200000);
date.toString("MMM dd"); // "Dec 20"
这篇关于如何将毫秒转换为可读日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文