How do I format a Microsoft JSON date?

后端 未结 30 3081
伪装坚强ぢ
伪装坚强ぢ 2020-11-21 04:48

I\'m taking my first crack at Ajax with jQuery. I\'m getting my data onto my page, but I\'m having some trouble with the JSON data that is returned for Date data types. Basi

30条回答
  •  误落风尘
    2020-11-21 05:10

    You can use this to get a date from JSON:

    var date = eval(jsonDate.replace(/\/Date\((\d+)\)\//gi, "new Date($1)"));
    

    And then you can use a JavaScript Date Format script (1.2 KB when minified and gzipped) to display it as you want.

提交回复
热议问题