How do I output an ISO 8601 formatted string in JavaScript?

后端 未结 14 1672
小鲜肉
小鲜肉 2020-11-22 08:41

I have a Date object. How do I render the title portion of the following snippet?



        
14条回答
  •  北荒
    北荒 (楼主)
    2020-11-22 09:02

    I was able to get below output with very less code.

    var ps = new Date('2010-04-02T14:12:07')  ;
    ps = ps.toDateString() + " " + ps.getHours() + ":"+ ps.getMinutes() + " hrs";
    

    Output:

    Fri Apr 02 2010 19:42 hrs
    

提交回复
热议问题