Search code examples
javascriptdatecountdown

converting a certain time format into a Date Object


I get this timestamp from an API "2015-04-03T19:04:00" and every week it will be updated. I want to use countdown.js and I have played around with it with the date in this format new Date(year, month, days, hour, minutes)...

it works:

$('.countTime').countdown({until : new Date(year, month, days, hour, minutes)})

basically I want to know the best way to convertthe string from the API to the date object I think that countdown.js accepts above. Do i split up the string into arrays by dashes and colons and delete the "T"? or is there a JavaScript function to convert the formats? Also I am concerned about it saying 19:04 when I was experimenting with it I used 12 hours not 24 hours. I wonder If I put in 19:04 and get the correct countdown


Solution

  • new Date('2015-04-03T19:04:00')