How to convert javascript string format to date

前端 未结 3 1162
-上瘾入骨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:39

    You could use a regex to get the value between the brackets and then pass that to the Date():

    var input = "/Date(-2208967200000)/";
    var matches = /\(([^)]+)\)/.exec(input);
    var date = new Date(parseInt(matches[1], 10));
    

    Example fiddle

提交回复
热议问题