Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / March 2006

Tip: Looking for answers? Try searching our database.

Web services date/time approach

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
markric@gmail.com - 28 Feb 2006 21:03 GMT
I'm working on a commercial application that will have data, web
service, and client application tiers. I have no control over where any
of these systems might be deployed, and it's fairly likely that users
running the client application will be in different time zones than the
web service and database server.

What I'd like to do is always store date/time values in the database in
UTC (GMT) format, and then convert them to local date/time values on
the client side. This should minimize the need to be concerned about
time zones in general.

I believe what's required here is that DateTime objects in .NET code
use the ToUniversalTime() function prior to be stored in the database
(a SQL Server in this case). Then I would always call ToLocalTime()
when I display any of these values in the client application. The
client will *always* go through an ASP.NET (ASMX) web service tier to
read/write any data (including date/time values).

Does this seem logical? Any gotchas that I'm overlooking? Just as an
aside, I'm using .NET 2.0 through all layers.

I'd very much appreciate any input, and thanks.

- Mark
Josh Twist - 04 Mar 2006 16:36 GMT
Hi Mark,

I thought this was a great question so I did a bit more research and
posted an article on my findings. Have a look and let me know what you
think: http://www.thejoyofcode.com/DateTime_in_Web_Services.aspx

Josh
http://www.thejoyofcode.com/
markric@gmail.com - 05 Mar 2006 12:58 GMT
Hi Josh,

Thanks very much for the informative reply. I performed similar testing
here, and arrived at a similar conclusion, but it was very helpful to
have another perspective.

I think that for my particular scenario, I'm creating a problem that
doesn't exist. I believe my confusion stemmed from the idea that SQL
Server doesn't store any time zone information, leading me to believe
that the stored value ultimately needed to be standardized in some
fashion and then converted at various endpoints.

However, if the web service layer always converts a stored datetime to
it's local time zone prior to transmitting it, and then the client
applications convert to their time zone again upon dipslay, then I
don't think it really matters. The .NET framework seems to handle the
details.

Thanks again for the input!

- Mark

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.