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:

http://localhost:8080/file/newcalendar?m=1455910939

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

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -