Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old August 7th, 2007, 05:02 PM
Authorized User
 
Join Date: Nov 2005
Location: , , .
Posts: 15
Thanks: 1
Thanked 0 Times in 0 Posts
Default time zone & day light time

question:

how to show datetime based on user selection. if user selects JAPAN, CST,EST,PST,KOREA whichever country while login, i need to show datetime in that country timezone eventhough server is EST (eastern standard time). Please include daylight saving time. REMEMBER: user system timezone remains same eventhough he changes country.

I used following code but doesnt work for countries that use daylight saving time.

oRptDt.ToUniversalTime.AddHours(iHrs).AddMinutes(i Mins)

where oRptDt is modified date time from db, ihrs is hours to add, imins is mins to add based on timezone (country) which he selected in screen.



detailed explanation:


Our website has (Asp.net 1.1) report that shows users with last modified date time.

I have to show this time based on the timezone selected by the user when logged in. Note: This timezone is NOT BASED on the user system but based on the selection he did during login in the website because the user may select diff timezone eventhough his system time zone remains same.

for e.g. If user selected EST, in db modified date time: 08/07/2007 1:50PM for a user, I have to show it as 08/07/2007 1:50PM because server is in EST but if the user selects japan, GMT+9, i have to show this modified datetime in japan time (so convert EST to GMT and then add 9hrs to it) and if he selects PST, i have to show GMT-8 but have to include daylight time zone.

I used following code but DOESTNT work for countries which have daylight time.

oRptDt.ToUniversalTime.AddHours(iHrs).AddMinutes(i Mins)

where oRptDt is modified date time from db, ihrs is hours to add, imins is mins to add based on timezone (country) which he selected in screen.

for japan, GMT+9, hrs to add is 9, mins to add is 0.

But this line of code doesnt work for US and other countries which uses daylight timezone. for e.g. when user select PST, the time is off by 1 hr in report. any idea or help is appreciated.


Similar Threads
Thread Thread Starter Forum Replies Last Post
date and time in EST time zone anboss XSLT 1 May 21st, 2008 01:42 PM
GMT(Time Zone) Help Mukesh Dubey ASP.NET 2.0 Professional 1 May 7th, 2008 09:18 PM
adjust zone time kherrerab BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 6 July 2nd, 2007 08:53 AM
Zone Time kherrerab BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 0 October 20th, 2006 12:30 PM
getting time zone nerssi Javascript 2 December 22nd, 2004 10:56 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.