javascript displaying a different date than php -
i have php script generates date object database value this:
$dt = new datetime($string_from_database); // in yyyy-mm-dd format $jsonvalue = $dt->format('u');
this retrieved js using ajax. feed jquery table this:
//datestart { 'sname': 'date_start', 'idatasort': 2, 'bsearchable': false, 'fnrender': function(obj) { var dstart = new date(parseint(obj.adata['datestartjson']) * 1000); var dend = new date(parseint(obj.adata['dateendjson']) * 1000); if (obj.adata['datestartjson'] == obj.adata['dateendjson']) return dstart.todatestring().substr(4); else return dstart.todatestring().substr(4) + ' -<br/>' + dend.todatestring().substr(4); } },
some users reporting js time displayed day earlier date displayed via php directly.
php displays: aug 24, 2013 js displays: aug 23, 2013
note: happens users, , cannot reproduce locally.
any ideas? jared
the javascript using local machine clock, while server spitting out server time. unless of users in same time zone server, you'll run issue. solution used many normalize server time utc, make appropriate calculations on client side javascript account delta.
Comments
Post a Comment