Getting unix timestamp from Date()

By | July 26, 2019


I can convert a unix timestamp to a Date() object by putting the long value into the Date() constructor. For eg: I could have it as new Date(1318762128031).

But after that, how can I get back the unix timestamp from the Date() object?


getTime() retrieves the milliseconds since Jan 1, 1970 passed to the constructor. It should not be too hard to get the Unix time (same, but in seconds) from that.

Rate this post

Leave a Reply

Your email address will not be published. Required fields are marked *