Use JavaScript to Parse Time

前端 未结 4 494
春和景丽
春和景丽 2021-02-04 14:13

This is probably something easy, but I\'m a bit confused how to do this. How can I, using JavaScript, parse only the time from the following ISO 8601 date string:



        
4条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-04 14:25

    Parsing the ISO timestamp is easy, formatting the time in a culturally appropriate way is hard (5:10 PM is not appropriate for all locales) Many toolkits provide routines for the ISO part, and it's even part of the new ECMAScript 5 standard; only a couple do the latter part, however.

    You can try dojo.date.stamp.fromISOString and dojo.date.locale.format.

    I believe Date-JS can format times also.

提交回复
热议问题