Search code examples
jquerytimeepoch

jquery convert number to date?


i have a json file that returns "date_created":"1273185387" in epoch format

i want to convert it to something like this Thu, 06 May 2010 22:36:27 GMT

any script to do this conversion?


Solution

  • var myObj = $.parseJSON('{"date_created":"1273185387"}'),
        myDate = new Date(1000*myObj.date_created);
    
    console.log(myDate.toString());
    console.log(myDate.toLocaleString());
    console.log(myDate.toUTCString());
    

    http://jsfiddle.net/mattball/8gvkk/