Solved

Calculate browser time on a website

Posted on 2011-03-16
3
283 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

This article provides a case study on how our local youth baseball league deployed a new website, including the platform selection, implementation and benefits to the league.
This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

760 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

17 Experts available now in Live!

Get 1:1 Help Now