How to convert javascript string format to date

前端 未结 3 1164
-上瘾入骨i
-上瘾入骨i 2021-01-26 17:57

In my ajax success I am getting result.Date as \"/Date(-2208967200000)/\". I need to check with the following date and proceed..<

3条回答
  •  被撕碎了的回忆
    2021-01-26 18:20

    Reference

    var jsonDate = "/Date(-2208967200000)/";
    var date = new Date(parseInt(jsonDate.substr(6)));
    alert(date);

    The substr function takes out the "/Date(" part, and the parseInt function gets the integer and ignores the ")/" at the end. The resulting number is passed into the Date constructor.

    jQuery dateFormat is a separate plugin. You need to load that explicitly using a tag.

提交回复
热议问题