0

Possible Duplicate:
Convert UTC Epoch to local date with javascript

In my project, I am receiving a JSON. it contains one field like

"displayDate":"1349137055814",

How can I convert to user readable (understandable, to be specific ;) ) form? For eg mm-dd-yyyy

And what is this format?

Community
  • 1
  • 1
AdityaParab
  • 7,024
  • 3
  • 27
  • 40

3 Answers3

1

new Date(milliseconds) creates a new date object using your millseconds value.

You can then use getYear, getDate, toLocaleFormat() or toUTCString to get your correct format.

NimChimpsky
  • 46,453
  • 60
  • 198
  • 311
1

You can convert it to a date using the Javascript Date object.

// Assuming 'result' contains your JSON

var myDate = new Date(result.displayDate);
Paul Alan Taylor
  • 10,474
  • 1
  • 26
  • 42
0

Use it this way

var d = new Date(1349137055814);
alert(d.getMonth()+ '/' + d.getDate() + '/' + d.getFullYear());

Check this demo

Sibu
  • 4,609
  • 2
  • 26
  • 38