Convert Json date to “Date” in javascript

后端 未结 3 800
轻奢々
轻奢々 2021-01-24 11:18

I am using Visual Studio 2013 with C#.

I am calling one ActionResult method that returns the list of data from Ajax.

The problem here is I am getting date as

3条回答
  •  独厮守ぢ
    2021-01-24 11:30

    In pure javascript, you can do this:

    var date = new Date(Number("/Date(1460008501597)/".replace(/\D/g, '')));
    

    Explanation:

    new Date(
        Number(
            "/Date(1460008501597)/".replace(/\D/g, '') // Removes all non digit characters
        ) // Cast it to numeric
    ) // Creates a new Date object with the resultant number
    

    Now, for more accurate solution for your problem, like display the date w/o javascript(which I think would be better choice), you can improve your question with more detail/information/code.

提交回复
热议问题