Javascript日期格式转换 [英] Javascript date format conversion
本文介绍了Javascript日期格式转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复:
使用javascript将UTC时代转换为本地日期
在我的项目中,
我收到一个JSON。它包含一个字段,如
displayDate:1349137055814,
pre>
如何转换为用户可读(可理解,具体;))表单?
例如mm-dd-yyyy
这是什么格式?
解决方案新日期(毫秒)使用你的毫秒值创建一个新的日期对象。
然后可以使用getYear,getDate,toLocaleFormat()或 toUTCString 以获取正确的格式。
Possible Duplicate:
Convert UTC Epoch to local date with javascriptIn my project, I am receiving a JSON. it contains one field like
"displayDate":"1349137055814",
How can I convert to user readable (understandable, to be specific ;) ) form? For eg mm-dd-yyyy
And what is this format?
解决方案new Date(milliseconds) creates a new date object using your millseconds value.
You can then use getYear, getDate, toLocaleFormat() or toUTCString to get your correct format.
这篇关于Javascript日期格式转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文