Javascript equivalent of php’s strtotime()?

There is not. The closest built-in option is Date.parse(), which parses a very limited subset of what strtotime() can:

var ts = Date.parse("2010-10-29");

It’s worth noting that this function returns milliseconds instead of seconds, so you need to divide the result by 1000 to get an equivalent value to PHP’s function.

Leave a Comment