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
Solved

Calculate browser time on a website

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Configure Robocopy to excluding folders 6 63
ROBOFTP UNZIP 1 53
Gotten a bit confused with my rather simple PowerShell script 3 29
remove computer from using logon script 17 38
This article will show, step by step, how to integrate R code into a R Sweave document
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.
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 fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

828 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