3

How do I convert this into timestamp

Datetime = 2014-07-14T09:34:47.000Z

Timestamp = ?

Ajey
  • 7,924
  • 12
  • 62
  • 86

2 Answers2

4
var Datetime = "2014-07-14T09:34:47.000Z";
new Date(Datetime).getTime();

This will return the number of milliseconds since the epoch.

dersvenhesse
  • 6,276
  • 2
  • 32
  • 53
Husman
  • 6,819
  • 9
  • 29
  • 47
1

Try this:

function getTimeStamp(dateStr) { //example: "2014-07-14T09:34:47"
  var s = new Date(dateStr); 
  return s.getFullYear()*10000000000 + (s.getMonth()+1)*100000000 + s.getDate()*1000000 + s.getHours()*10000 + s.getMinutes()*100 + s.getSeconds();
}

Note that you have to remove the milliseconds from your example.

zarkobehar
  • 211
  • 2
  • 5