block by joyrexus 8258933

Convert dates to milliseconds

We can convert numbers (representing time in milliseconds) to dates (and vice versa).

Create a new Date object:

now = new Date()        # Sat Jan 04 2014 12:39:41 GMT-0600 (CST)

Convert the Date object to an integer representing the number of milliseconds since UNIX epoch:

time = +now             # 1388860781079

Convert time in milliseconds back to a Date object:

date = new Date(time)   # Sat Jan 04 2014 12:39:41 GMT-0600 (CST)

index.coffee