javascript - Moment.js not accepting query string as valid input -
i have following function converts query string moment (or date) object. i've run bunch of tests , basically moment.js doesn't seem accept req.query.m valid string. moment works fine if hardcode input, , i'm able query string itself.
the query string is:
app.get('/file/newcalendar', function(req, res) { var dateselect = req.query.m; var selecteddate = moment(req.query.m); var selectedmonth = selecteddate.month(); jsontest = { 'testquery': dateselect, 'testmomentonquery': moment(req.query.m), 'testmomentonvariable': moment(dateselect), 'testmomentmonth': moment(12345678).month(), }; res.json(jsontest); })
i've tried using date() instead of moment.
app.get('/file/newcalendar', function(req, res) { var selecteddate = date(req.query.m); var selectedmonth = selecteddate.getmonth(); jsontest = { 'selecteddate': selecteddate, 'selectedmonth': selectedmonth, }; res.json(jsontest); })
date() works fine instead .getmonth() function gets
typeerror: selecteddate.getmonth not function @ object.handle
thanks in advance!
Comments
Post a Comment