Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.net Webservice Date Parameter Timezone Offset Problem

I have an asp.net webservice with a parameter of type datetime. I have noticed asp.net seems to offset the date based on the clients timezone.

I need to disable this functionality. I simply want to pass a date (i.e. 3/15/2009) to the webservice from javascript without any timezone context.

Is my only option to change the parameter type to string then convert it server side, or is there some way to disable the deserializer from offsetting my date param ?

like image 359
Element Avatar asked Jan 31 '26 08:01

Element


2 Answers

I'd use a string.

It kind of makes sense - a DateTime is really a "point in time", so when two clients are talking about the same DateTime, they're talking about the same INSTANT. So saying "the meteor will hit earth in 5 minutes", should adjust itself to the timezone.

like image 193
Ilya Tchivilev Avatar answered Feb 03 '26 02:02

Ilya Tchivilev


You could use a UTC date instead: http://www.java2s.com/Code/JavaScript/Date-Time/GetUTCDate.htm

like image 20
Jonathan Parker Avatar answered Feb 03 '26 00:02

Jonathan Parker



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!