TDG
TDG

Reputation: 1302

JavaScript - convert date format to seconds

How can I change this date format to seconds?

<div class="calendar" data-fixeddate="July 16, 2017 00:05 am">...</div>

Can we convert using JavaScript or JQuery?

Upvotes: 1

Views: 2834

Answers (1)

Joey
Joey

Reputation: 670

Try this in your browser console:

new Date('July 16, 2017 00:05 am').getTime() / 1000

Date.getTime returns the date in milliseconds, divide by 1000 to get seconds.

Additional information about Date.getDate may be read at: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTime

Upvotes: 1

Related Questions