Convert DateTime To JSON DateTime

前端 未结 7 1113

I have a WebService which return DateTime Field.

I get a result /Date(1379048144000)/ but

i want just 1379048144000 how can i ach

7条回答
  •  青春惊慌失措
    2020-12-16 22:03

    U can always solve your problem when sending a date in a JSON object to JS by converting the date as follows:

    var myJSDate = (new Date(parseInt(obj.MyDate.substr(6)))).toJSON();
    

    Where obj.Date contains the date you wanna format.

    Then u'll get something like this: "2013-10-25T18:04:17.289Z"

    U can always check it in Chrome console by writing:

    (new Date()).toJSON();
    

    Hope this helps!

提交回复
热议问题