如何在jQuery中将DateTime值转换为dd/mm/yyyy? [英] How to convert a DateTime value to dd/mm/yyyy in jQuery?
本文介绍了如何在jQuery中将DateTime值转换为dd/mm/yyyy?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在jQuery中有一个datetime对象,其值是:/Date(1475173800000)/.我希望将其显示在jQuery中的 dd/mm/yyyy 中.有什么办法可以实现?
I am having a datetime object whose value is: /Date(1475173800000)/ in jQuery. I want it to be displayed in dd/mm/yyyy in jQuery. Is there any way to achieve it?
推荐答案
您可以将new Date()
与参数用作通用时间变量,将Date.prototype.toJSON()
,String.prototype.slice()
,String.prototype.split()
与参数"-"
,Array.prototype.reverse()
一起使用,Array.prototype.join()
和参数"/"
You can use new Date()
with parameter being universal time variable, Date.prototype.toJSON()
, String.prototype.slice()
, String.prototype.split()
with parameter "-"
, Array.prototype.reverse()
, Array.prototype.join()
with parameter "/"
var time = 1475173800000;
var date = new Date(time).toJSON().slice(0, 10).split("-").reverse().join("/");
console.log(date);
这篇关于如何在jQuery中将DateTime值转换为dd/mm/yyyy?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文