javascript - How to let the return Json(datetime) return millisecondes according to the UTC? -


i have function retrieves event dates(json format) ajax. function should convert date human friendly format. working not perfectly. problem is: when server date "21/06/2013 22h00" function returns "22/06/2013 05h00" "26/07/2013 18h30" function returns "27/07/2013 01h30"

which 6 hours of advance.

ps: between country , country server located, there difference of 6 hours..

where have put utc function? what's realy wrong function? thank you

here code:

var jsonifymydate = function (jsondate) {            var parser = parseint(jsondate.substr(6));            if (parser > 0 && !isnan(parser)) {                var newdate = new date(parser),                _date = newdate.getdate(),                _month = newdate.getmonth() + 1,                _year = newdate.getfullyear(),                _hour = newdate.gethours(),                _minute = newdate.getminutes();                var datestr = (_date < 9 ? "0" : "") + _date;                datestr += "/" + (_month < 9 ? "0" : "") + _month;                datestr += "/" + _year;                datestr += " "+(_hour < 9 ? "0" : "") + _hour + "h";                datestr += (_minute < 9 ? "0" : "") + _minute;                /* + "-" + newdate.getseconds() + "-" + newdate.getmilliseconds() + "";*/                return datestr;            } else return ""; 

update: can see problem server side parsing function within actionresult... so, using asp.net+mvc(c#), how let

return json(datetime); 

return utc millisecondes instead of server's 1 ?

json formate created based on utc datetime.

after getting datetime ajax call, have convert utc datetime in local datetime zone.

ex:

var date = new date('6/29/2011 4:52:48 pm utc'); date.tostring() // "wed jun 29 2011 09:52:48 gmt-0700 (pdt)" 

Comments