C# Tutorials and offshore development in India
Tutorials Resources Forum Reviews Communities Interview Jobs Projects Training Videos


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...


Birthday Greetings
Learn Windows 7: What to do when a USB device not recognised in Windows 7    If you are getting an error message saying that USB device not recognized when you plug in a USB device, here is a method to fix this problem.



Resources » Code Snippets » Javascript »

Outputting the Date and Time in a Selected Time Zone


Posted Date: 20 Sep 2009    Resource Type: Code Snippets    Category: Javascript
Author: datta gunturuMember Level: Gold    
Rating: 1 out of 5Points: 7



Hello Friends,

Outputting the Date and Time in a Selected Time Zone



Some you required to show datatiem depending on the zones and some time you need to to show more than one zone's time

Doing this requires the use of two methods of the Date object:
getTimezoneOffset: This method returns the number of minutes’
difference between the current browser’s time zone and GMT time.
setHours: This method is used to determine the hours part of the
time in the current Date object. Using this you could reset the time
to the time in your time zone.

The following code slove the above issue:.

<script type="text/javascript">
var myOffset = -2;
var currentDate = new Date();
var userOffset = currentDate.getTimezoneOffset()/60;
var timeZoneDifference = userOffset - myOffset;
currentDate.setHours(currentDate.getHours() + timeZoneDifference);
document.write(“The time and date in Central Europe is: “ + currentDate.toLocaleString());

</script>

Thanks & Regards,
Datta.G





Responses to the resource: "Outputting the Date and Time in a Selected Time Zone"

No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Outputting the Date and Time in a Selected Time Zone  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Scheduling and Canceling the Functions
Previous Resource: Randomizing Your Slide Show using JavaScript
Return to Resources
Post New Resource
Category: Javascript


Post resources and earn money!
 
More Resources



About Us    Contact Us    Privacy Policy    Terms Of Use