.net - Why is there time difference between client and server on localhost -


application running on localhost. server 1 hour earlier client!

client sends time : sat apr 25 2015 00:00:00 gmt-0400 (eastern daylight time)

enter image description here

request sent: dateofarrival: "2015-04-25t04:00:00.000z"

enter image description here

server receives time: {4/24/2015 11:00:00 pm}

enter image description here

why there 1 hour difference between , how can handle it? guess somehow related daylight time vs standart time.

when try code:

string datestr = "2015-04-25t04:00:00.000z";   var mydate = datetime.parse(datestr);  // gives me mydate = {4/25/2015 12:00:00 am} 

actually interested day part of time. in db, holding date type. because of time difference, days goes 1 day before.

i tried various ways handle issue got lost in datetime conversion world! lost on localhost application, not imagine happen on live server.

i think this q&a mentions similar issue, can't figure out if matters:

my timezone: eastern time zone (utc-05:00)

about web api odata json serializer, from post other this one

here server code:

// patch: odata/incomingstudents(5) [acceptverbs("patch", "merge")] public async task<ihttpactionresult> patch([fromodatauri] int key, delta<incomingstudent> patch) {     validate(patch.getentity());     var dateofarrival = patch.getentity().dateofarrival ...  } 

client angularjs sending http patch request

to avoid timezone differences between client , server (or differing configurations within same machine) want use utc transfers , storing in databases.

meaning, on server side, might need datetime.touniversaltime() adjust date, or datetime.utcnow current date & time.

from javascript might idea use moment.js ease handling of dates.

using moment.js, value in utc in following manner:

var localdate = new date(); var inutc = moment(localdate).utc(); 

you'd display information user in local offset, send server , receive using utc.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -