Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 7th, 2008, 10:03 AM
Registered User
 
Join Date: May 2008
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default GMT(Time Zone) Help

Hi All,

I have to implement GMT (Time Zone) in my project. I have not idea about this.
I have Time Zone Drop Menu with country's GMT. How to implement this ?

plz help.
Thanks,
Mukesh







  #2 (permalink)  
Old May 7th, 2008, 09:18 PM
Authorized User
 
Join Date: Oct 2007
Location: Everett, WA, USA.
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Myself, I store all dates as GMT time. Always.
In SQL this means using getUTCDate() instead of getDate()

Then when I present dates to users I use JavaScript (client side) to automatically calculate the dates to local time based on their local computer settings.

This function is an example of how you can determine the timezone offset and whether or not the user is observing Summer Time (aka "Daylight Savings Time")

Code:
function checkTimeZone() {
   var rightNow = new Date();
   var date1 = new Date(rightNow.getFullYear(), 0, 1, 0, 0, 0, 0);
   var date2 = new Date(rightNow.getFullYear(), 6, 1, 0, 0, 0, 0);
   var temp = date1.toGMTString();
   var date3 = new Date(temp.substring(0, temp.lastIndexOf(" ")-1));
   var temp = date2.toGMTString();
   var date4 = new Date(temp.substring(0, temp.lastIndexOf(" ")-1));
   var hoursDiffStdTime = (date1 - date3) / (1000 * 60 * 60);
   var hoursDiffDaylightTime = (date2 - date4) / (1000 * 60 * 60);
   if (hoursDiffDaylightTime == hoursDiffStdTime) { 
      alert("Time zone is GMT " + hoursDiffStdTime + ".\nDaylight Saving Time is NOT observed here.");
   } else {
      alert("Time zone is GMT " + hoursDiffStdTime + ".\nDaylight Saving Time is observed here.");
   }
}
I make it complicated for a good reason. Browser versions differ in their calculation for time zone offsets. It took me 3 months using over 15 different popular browsers and versions and each and every one of them returned different values. The script above works the same for any browser I tested.

This script should get you pointed in the right direction.

Hope it helps.

Regards,
Charles Forsyth

 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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
time zone & day light time rajn ASP.NET 1.0 and 1.1 Professional 0 August 7th, 2007 05:02 PM
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
To get the gmt time using Crystal reports pallavi BOOK: Professional Crystal Reports for VS.NET 0 August 24th, 2004 06:10 AM



All times are GMT -4. The time now is 03:07 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.