Solved

Calculate browser time on a website

Posted on 2011-03-16
3
284 Views
Last Modified: 2012-05-11
Hi,

We have a requirement to show a day/night functionality on a website - when a user accesses the website, depending on the user's timezone, a different template will load for the same website to depict whether it is day/night.

We have put in a script  which however does not behave correctly at times. There have been many instances when we have logged in during the day to see the night template or vice -versa. We have also noticed that the script does not work in Safari browser.

Does anyone know of a script/function that will satisfy our requirement and is browser compatible?

Thanks
0
Comment
Question by:Web_Sight
3 Comments
 
LVL 16

Expert Comment

by:Brian Pringle
ID: 35147203
Your best bet would be to do this as a server-side script.  Are you using PHP or ASP?  If so, you could do it there and not leave it up to the Web browser to make the decision.  This would make it cross-platform and would allow your server to control it -- not the end user's computer.
0
 
LVL 3

Accepted Solution

by:
Maximus5684 earned 500 total points
ID: 35201992
If you have no way of asking the user directly (like during a sign-up process), then you can use:

new Date().getTimezoneOffset()/60;

You can then use that information to dynamically change the template that is applied with JavaScript or, to make it easy on yourself, jQuery:

http://www.cssnewbie.com/simple-jquery-stylesheet-switcher/
0
 

Author Closing Comment

by:Web_Sight
ID: 35350346
Not an exact answer
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Windows 10 Search (Indexing Options) Modify with PS, CMD or Registry. 5 63
exchange, scripts 3 61
javascript to html map 8 66
Disk Ram Peak 1 33
Introduction In this tutorial, I'll explain how to create an animated progress meter in a wireframe prototype developed using Axure RP 7.0 - a leading prototyping tool for designing web sites and software. (For more information about Axure and gett…
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
The purpose of this video is to demonstrate how to set up the permalinks on a WordPress Website. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Go t…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

27 Experts available now in Live!

Get 1:1 Help Now