How to convert a DateTime value to dd/mm/yyyy in jQuery?

前端 未结 3 1920
陌清茗
陌清茗 2021-01-16 04:57

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

3条回答
  •  情话喂你
    2021-01-16 05:33

    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);

提交回复
热议问题