javascript - Creating Date objects from date string query parameter -
so have action accepts iso 8601 string through query parameter fromdate
. example request (encoded) action such http://localhost:1337/createfromdate?fromdate='2016-05-24t04%3a18%3a38.000z'
the issue notice when initializing date object fromdate parameter, invalid date returned. however, when hardcode same exact string, creates date object no problem.
the server-side code looks this:
createfromdate: function(req,res){ console.log(new date(req.query.fromdate)); // invalid date console.log(new date('2016-05-24t04:18:38.000z')); // mon may 23 2016 21:18:38 gmt-0700 (pdt) res.ok() }
am missing something? thanks.
Comments
Post a Comment