473,804 Members | 2,147 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DateTime time zone conversions not required !

Would appreciate some insight into how people are dealing with the
implicit conversion of timezones that .NET does.

If a server in one timezone delivers up a typed dataset to a component
in another (winform for example) then the timezone conversion takes
place. This is a pain if you are doing date based calculations on the
client using input in one timezone and data from another. (Take one
hour off a CET time and you go a day back in terms of days...)

What are people doing to conteract this? What are some sample
strategies? Any sample code to simply STOP this would help, but I
suspect there are more far reaching implications...

Thanks
Nov 15 '05 #1
4 15246
GiriT,

.NET shouldn't be doing anything to the dates to change them when you
are returning (and I have heard of no such feature). Is it possible that
this is happening on the database level, or some other level which you are
not aware of?

To get around things like this, I make sure that all dates stored in the
database are in UTC, and I do modification on them locally if need be.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- nick(dot)paldin o=at=exisconsul ting<dot>com

"GiriT" <gt******@prolo gis.com> wrote in message
news:f1******** *************** ***@posting.goo gle.com...
Would appreciate some insight into how people are dealing with the
implicit conversion of timezones that .NET does.

If a server in one timezone delivers up a typed dataset to a component
in another (winform for example) then the timezone conversion takes
place. This is a pain if you are doing date based calculations on the
client using input in one timezone and data from another. (Take one
hour off a CET time and you go a day back in terms of days...)

What are people doing to conteract this? What are some sample
strategies? Any sample code to simply STOP this would help, but I
suspect there are more far reaching implications...

Thanks

Nov 15 '05 #2

Hi ,

The TimeZone converstion at lease take place when you serialize the
DateTime object.
You can just follow Nicholas' suggestion, convert the DateTime object into
UTC.
I think you also can convert your DateTime object into a string and after
received construct a new DateTime object.

Hope this helps,

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| From: gt******@prolog is.com (GiriT)
| Newsgroups: microsoft.publi c.dotnet.langua ges.csharp
| Subject: DateTime time zone conversions not required !
| Date: 10 Oct 2003 05:25:45 -0700
| Organization: http://groups.google.com
| Lines: 14
| Message-ID: <f1************ **************@ posting.google. com>
| NNTP-Posting-Host: 193.67.177.98
| Content-Type: text/plain; charset=ISO-8859-1
| Content-Transfer-Encoding: 8bit
| X-Trace: posting.google. com 1065788745 12856 127.0.0.1 (10 Oct 2003
12:25:45 GMT)
| X-Complaints-To: gr**********@go ogle.com
| NNTP-Posting-Date: Fri, 10 Oct 2003 12:25:45 +0000 (UTC)
| Path:
cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!new sfeed00.sul.t-online.de!t-onlin
e.de!news-spur1.maxwell.s yr.edu!news.max well.syr.edu!po stnews1.google. com!no
t-for-mail
| Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.csharp:1905 27
| X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.csharp
|
| Would appreciate some insight into how people are dealing with the
| implicit conversion of timezones that .NET does.
|
| If a server in one timezone delivers up a typed dataset to a component
| in another (winform for example) then the timezone conversion takes
| place. This is a pain if you are doing date based calculations on the
| client using input in one timezone and data from another. (Take one
| hour off a CET time and you go a day back in terms of days...)
|
| What are people doing to conteract this? What are some sample
| strategies? Any sample code to simply STOP this would help, but I
| suspect there are more far reaching implications...
|
| Thanks
|

Nov 15 '05 #3
What is interesting is the following:

The database has a date as 10 Oct 1999 00:00 (ie midnight)

A webservice in CET (GMT+1) plucks this out of the database into a typed
dataset.

If you go direct to the webservice from a browser and use the VS.NET harness
you see the right date.

A component in a different timezone GMT receives this typed dataset. When
you then access the typed dataset's date field it has become.... 11 Oct
1999 22:00. Now this is strictly speaking correct as that is the time GMT
if you take daylight saving into account...

My problem is that all my dates are in as midnight... I don't care about
the "time" as such so converting to and from UTC is not realistic as the
dates when entered by the user into the system are specified as just dates
not daae and time in their timezone....

Luckily for me .Subtract returns a TimeSpan object, whose Days property is
returning the correct result (can you confirm this ?).

This doesn't resolve whether I should be :

a) Letting dates go in as midnight but then use .ToLocalTime() in the
timezone.
b) Engage in the complexity of dealing with time and convert to UTC on the
way in and ToLocal on the way out..
b) Any other strategy...

Be grateful for any advice on this.
Nov 15 '05 #4

Hi Giri,

I think a sample and easy to implement way of avoiding the timezone
conversion is convert the Datetime object to string, then in client side,
you can again convert the string into DateTime object.
If you want to do the timezone conversion, I think you should store the UTC
in server side and use tolocal method in client side.

Hope this helps,
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| From: "Giri" <gt******@prolo gis.com>
| References: <f1************ **************@ posting.google. com>
<Xk************ **@cpmsftngxa06 .phx.gbl>
| Subject: Re: DateTime time zone conversions not required !
| Date: Tue, 21 Oct 2003 09:21:52 +0100
| Lines: 34
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <ua************ *@TK2MSFTNGP10. phx.gbl>
| Newsgroups: microsoft.publi c.dotnet.langua ges.csharp
| NNTP-Posting-Host: 193.67.177.98
| Path: cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!TK2 MSFTNGP10.phx.g bl
| Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.csharp:1927 93
| X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.csharp
|
| What is interesting is the following:
|
| The database has a date as 10 Oct 1999 00:00 (ie midnight)
|
| A webservice in CET (GMT+1) plucks this out of the database into a typed
| dataset.
|
| If you go direct to the webservice from a browser and use the VS.NET
harness
| you see the right date.
|
| A component in a different timezone GMT receives this typed dataset. When
| you then access the typed dataset's date field it has become.... 11 Oct
| 1999 22:00. Now this is strictly speaking correct as that is the time GMT
| if you take daylight saving into account...
|
| My problem is that all my dates are in as midnight... I don't care about
| the "time" as such so converting to and from UTC is not realistic as the
| dates when entered by the user into the system are specified as just dates
| not daae and time in their timezone....
|
| Luckily for me .Subtract returns a TimeSpan object, whose Days property is
| returning the correct result (can you confirm this ?).
|
| This doesn't resolve whether I should be :
|
| a) Letting dates go in as midnight but then use .ToLocalTime() in the
| timezone.
| b) Engage in the complexity of dealing with time and convert to UTC on the
| way in and ToLocal on the way out..
| b) Any other strategy...
|
| Be grateful for any advice on this.
|
|
|

Nov 15 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2531
by: Max M | last post by:
# -*- coding: latin-1 -*- """ I am currently using the datetime package, but I find that the design is oddly asymmetric. I would like to know why. Or perhaps I have misunderstood how it should be used? I can make a datetime easily enough
2
1791
by: Daniel Jung | last post by:
Hi 1088553069 => Wed Jun 30 01:51:22 2004 CEST I can do the time INT string substitution, but I want a set of "country codes", in order for my users to be able to pick their own preferences. This set should include American and European date format (`month/day' vs. `day.month'), American and European time (AM/PM vs. 24hours).
3
2621
by: Mark | last post by:
Hey everybody. Is there an easy way in vb.net to convert the local time of a machine to US CST ? My machines are distributed throughout and the server is requesting we send the time of the txns in US CST. TIA, Mark
11
7258
by: Cor Ligthert | last post by:
Hello everybody, Jay and Herfried are telling me every time when I use CDate that using the datetime.parseexact is always the best way to do String to datetime conversions. They don't tell why only that I have to listen to them because they know it better. They told also that in a business situation it is better to use datetime.parseexact for changing cultures and not to use the globalization setting. I did not give them this sample,...
9
4933
by: Phil B | last post by:
I am having a problem with a datetime from a web services provider The provider is sending the following SOAP response <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tns="urn:JadeWebServices/WebServiceProvider/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
12
61223
by: conckrish | last post by:
Hi all.. Can anyone tell me how to compare datetime objects?I ve three objects namely Current date,start date and end date.. I need to check the current date with Start date and end date....Plz tell me how to compare ??? Thanx.. Krish
9
9370
by: Abhishek | last post by:
Hi I am trying to deserialize/ Parse a datetime object with the below string "2007-05-14T08:00:00.000+02:30" . If i am in GMT + 2.30 time zone everything's fine however if i am in GMT + 5.30 i get the DateTime object which represents 11.00 AM. Now this is perfectly fine as if i go from GMT +2.30 tp GMT + 5.30 , 8.00 AM becomes 11.00 AM. however this is not what i want to achieve in my program. What i want to achieve is to reconstruct a...
2
5082
by: nightwatch77 | last post by:
Hi, does anyone know why .Net incorrectly handles time zone conversion when passing DateTime through web services? The problem is that it seems to ignore the time zone part. My time zone is CEST, that is GMT +01:00 + daylight saving. And the web service handles datetimes correctly provided that they are also in CEST. But when some client calls my web service passing dates in UTC, the .Net runtime just ignores that fact and takes just the...
2
1379
by: Andy B | last post by:
I have a few questions about xml, DateTime conversions and DateTime fields. 1. in the example of DateTime.Now, how would you save it in the format yyyy-mm-ddThh:mm:ssZ for xml storage? 2. If I have an xml attribute date="2008-09-25T13:15:00Z", How would I load that into a DateTime variable? 3. Where can I get a list of valid time zone codes for use in xml storage? Thanks for your help and answers. P.S. My codebehind is VB.net in...
0
9711
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9593
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10343
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10335
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9169
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7633
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4306
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3831
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.