Javascript Date String Parsing

1 · Alan Storm · April 29, 2021, 1:40 p.m.
One of my favorite features of PHP is the strtotime function. This function lets you pass in a date string and have a unix timestamp returned $time = strtotime('2021-04-01'); echo date('c',$time),"\n"; // outputs // 2021-04-01T00:00:00-07:00 What’s great about it is it works with a variety of date formats. $time = strtotime('04/01/2021'); echo date('c',$time),"\n"; // outputs // 2021-04-01T00:00:00-07:00 And don’t worry — if you’re all objects all the time the same string parsing behavior works ...