Format Date as “yyyy-MM-dd'T'HH:mm:ss.SSS'Z'”

后端 未结 5 560
囚心锁ツ
囚心锁ツ 2021-02-02 05:49

I need to format a date as yyyy-MM-dd\'T\'HH:mm:ss.SSS\'Z\' as specified by Parse\'s REST API for Facebook. I was wondering what the most lightweight

5条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-02 06:22

    Call the toISOString() method:

    var dt = new Date("30 July 2010 15:05 UTC");
    document.write(dt.toISOString());
    
    // Output:
    //  2010-07-30T15:05:00.000Z
    

提交回复
热议问题