最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Date format "Date(1394841600000)"?(In ticks) - Stack Overflow

programmeradmin0浏览0评论

I retrieved a date from my database table which was of the format : DD-MM-YYYY HH:MM:SS.FFF and saved it in a dynamic variable which was then passed to the JavaScriptSerializer class to make it a JSON object and I got the format: "\/Date(1394841600000)\/" for the date. I'm not sure why this is ing and I cant find this format in any of the standard date format lists.

Can anyone tell me what this format is? Or better, how to parse this to get my original format back using javascript?

I retrieved a date from my database table which was of the format : DD-MM-YYYY HH:MM:SS.FFF and saved it in a dynamic variable which was then passed to the JavaScriptSerializer class to make it a JSON object and I got the format: "\/Date(1394841600000)\/" for the date. I'm not sure why this is ing and I cant find this format in any of the standard date format lists.

Can anyone tell me what this format is? Or better, how to parse this to get my original format back using javascript?

Share Improve this question edited Mar 19, 2014 at 6:38 Mkl Rjv asked Mar 18, 2014 at 10:25 Mkl RjvMkl Rjv 6,9335 gold badges32 silver badges48 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 5

It is date in ticks since midnight Jan 1, 1970 to the date of object.

To convert use:

var myDate = new Date("/Date(1394841600000)/".match(/\d+/)[0] * 1);

Here is Demo

Try this :

var myDate = new Date(parseInt('/Date(1354348015481)/'.substr(6)));

The format is milliseconds from UNIX epoch. What you see is basically a JSON friendly variant of new Date(1394841600000). For example try this:

var date = new Date(1394841600000);

console.log(date);
发布评论

评论列表(0)

  1. 暂无评论