Search code examples
javascriptdatejs

If I have a time like 1325982833403 in JavaScript, how do I convert it to a datejs value?


The JavaScript library I'm using represents user login times as long integers:

1325982833403

How do I convert this to a DateTime ('MM/dd/yyyy hh:mm tt') value that the datejs library would understand?


Solution

  • Using Date constructor:

    var date = new Date(1325982833403*1000);
    

    That number is Unix timestamp, google for more information about this, and conversion techniques