Ember.js and Dates - showing as one day earlier than actual -


this has been giving me trouble long time now, , wouldn't think hard. have model dates, , date data coming api so:

{   ...   tollgate1: '2016-04-15',   tollgate2: '2017-01-01',   projectclose: '2016-10-21', } 

i created format-date helper (which uses moment.js) format dates in view mode, so: viewing dates

and that's shows correctly. however, when switch edit mode, input elements still referencing same values, go 1 day earlier! editing dates

this has been maddening time. i've thought might due of time zone information in data, since can't change data that's fed app, how can display date in data, regardless of timezone? example, tollgate 1 date, want show april 15 no matter user in world.

okay, many things, isn't ember thing javascript thing. it's really hard learning both @ once!

since dates coming down api don't have time zone, they're assumed gmt, , est timezone of -4 hours makes show day before. apparently moment.js has built-in handling that's why format-date helper works fine.

what did solve add computed properties on model each date, , create new date object pulling out parts input date, so:

function convertdatetoutc(d) {   if(d) {     return new date(d.getutcfullyear(), d.getutcmonth(), d.getutcdate());   } else {     return null;   } }  export default ds.model.extend({ ...   tollgate1date: ember.computed('tollgate1', function() {     return convertdatetoutc(this.get('tollgate1'));   }) }); 

Comments