javascript - "getDate().toJSON()" loses a day -


i'm using pikaday date picker plugin (through angular directive , momentjs) , sending value server. converting json seems lose day though:

var d = mypikaobject.getdate(); console.log(d);              // thu apr 30 2015 00:00:00 gmt+0200 (sast) console.log(d.tojson());     // 2015-04-29t22:00:00.000z 

i think momentjs problem have no idea what's going wrong.

giving you're getting time momentjs, can try moment.utc() method. docs say:

as of version 2.0.0, locale key can passed third parameter moment() , moment.utc()

moment('2012 juillet', 'yyyy mmm', 'fr'); moment('2012 july',    'yyyy mmm', 'en'); 

you can lot more utc() method.

moment.utc(); moment.utc(number); moment.utc(number[]); moment.utc(string); moment.utc(string, string); moment.utc(string, string[]); moment.utc(string, string, string); moment.utc(moment); moment.utc(date); 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -