Solved

Calculate browser time on a website

Posted on 2011-03-16
3
288 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

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

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

728 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