Skip to content Skip to sidebar Skip to footer

Javascript Date Format Conversion

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 co

Solution 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.

Solution 2:

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

// Assuming 'result' contains your JSONvar myDate = newDate(result.displayDate);

Solution 3:

Use it this way

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

Check this demo

Post a Comment for "Javascript Date Format Conversion"