In javascript, if I specify the date as MM/DD/YYYY
, I can use new Date()
to parse it as the local timezone:
>>> new Date('01/01/1970')
Date {Thu Jan 01 1970 00:00:00 GMT-0500 (EST)}
However, if I specify the date as YYYY-MM-DD
, it assumes that I'm giving the date in the UTC timezone:
>>> new Date('1970-01-01')
Date {Wed Dec 31 1969 19:00:00 GMT-0500 (EST)}
Is there an easy way to tell the date parser to use the local timezone when parsing 'YYYY-MM-DD' dates? Or do I need to use .replace(/^(\d{4})-(\d{2})-(\d{2})$/, '$2/$3/$1')
to fix it first?