473,785 Members | 2,457 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DST & getTimezoneOffs et()

I'm writing a backend web app for a company that only has locations in
the US. Why can't I, at login, pull their getTimezoneOffs et() using
javascript, cookie it, then when I need to show a local time compute
the difference in their value in the cookie vs. my server's value?

I've seen a million articles about factoring in DST, but when my server
(which is in PA) switches to DST won't the difference value remain the
same since everyone rolls into DST on the same date?

For example, in June the server offset is 4 and in California the
offset is 7. But in December the server is at 5 and California it's 8.
So it's always a difference of 3. No?

Sep 14 '06 #1
2 5768

bo*****@gmail.c om wrote:
I'm writing a backend web app for a company that only has locations in
the US. Why can't I, at login, pull their getTimezoneOffs et() using
javascript, cookie it, then when I need to show a local time compute
the difference in their value in the cookie vs. my server's value?
You could do that, but it won't work in all cases (see below).
>
I've seen a million articles about factoring in DST, but when my server
(which is in PA) switches to DST won't the difference value remain the
same since everyone rolls into DST on the same date?
No -- because not everyone observes DST.
>
For example, in June the server offset is 4 and in California the
offset is 7. But in December the server is at 5 and California it's 8.
So it's always a difference of 3. No?
Your best bet is to figure out what timezone they're actually in then
use timestamps appropriately when parsing and displaying dates and
times. Timestamps are in UTC which doesn't have DST. The timezone
setting of the machine will determine how dates are parsed (via
strtotime()) and how they are displayed (with date()) and will take
care of DST for you automatically.

Here's what you really want to do:

Call date_default_ti mezone_set() with your home timezone in PA at the
top of all your pages. This is optional since PHP will take it from
the server, but recommended nonetheless.

If you want the current date and time, get the timestamp from the
time() function.

Before calling date() to format a date for display, call
date_default_ti mezone_set() with the user's timezone.

This will take care of all the converting for you and accomdate DST
automatically.

Sep 14 '06 #2
I forgot to mention ... I'm running PHP 4.3.4, so I don't have access
to date_default_ti mezone_set(). :(
Before calling date() to format a date for display, call
date_default_ti mezone_set() with the user's timezone.
Do I still use javascript to get the user's timezone? If so, how does
that differ from my original idea? I'm still using the difference
between my server's timezone and the user's timezone to figure out how
to adjust the time, no?

Sorry -- time/date stuff always sends my head spinning.

ZeldorBlat wrote:
bo*****@gmail.c om wrote:
I'm writing a backend web app for a company that only has locations in
the US. Why can't I, at login, pull their getTimezoneOffs et() using
javascript, cookie it, then when I need to show a local time compute
the difference in their value in the cookie vs. my server's value?

You could do that, but it won't work in all cases (see below).

I've seen a million articles about factoring in DST, but when my server
(which is in PA) switches to DST won't the difference value remain the
same since everyone rolls into DST on the same date?

No -- because not everyone observes DST.

For example, in June the server offset is 4 and in California the
offset is 7. But in December the server is at 5 and California it's 8.
So it's always a difference of 3. No?

Your best bet is to figure out what timezone they're actually in then
use timestamps appropriately when parsing and displaying dates and
times. Timestamps are in UTC which doesn't have DST. The timezone
setting of the machine will determine how dates are parsed (via
strtotime()) and how they are displayed (with date()) and will take
care of DST for you automatically.

Here's what you really want to do:

Call date_default_ti mezone_set() with your home timezone in PA at the
top of all your pages. This is optional since PHP will take it from
the server, but recommended nonetheless.

If you want the current date and time, get the timestamp from the
time() function.

Before calling date() to format a date for display, call
date_default_ti mezone_set() with the user's timezone.

This will take care of all the converting for you and accomdate DST
automatically.
Sep 15 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
8580
by: Collin VanDyck | last post by:
I have a basic understanding of this, so forgive me if I am overly simplistic in my explanation of my problem.. I am trying to get a Java/Xalan transform to pass through a numeric character reference (i.e.  ) and it seems to be converting the character to its UNICODE representation. Take this source XML document: <?xml version="1.0" encoding="UTF-8"?>
1
11444
by: DrTebi | last post by:
Hello, I have the following problem: I used to "encode" my email address within links, in order to avoid (most) email spiders. So I had a link like this: <a href="mailto:DrTebi@yahoo.com">DrTebi</a> This would work like a regular mailto link in any browser, but wouldn't be visible to spiders if they don't have a function to decode it.
0
2423
by: Thomas Scheffler | last post by:
Hi, I runned in trouble using XALAN for XSL-Transformation. The following snipplet show what I mean: <a href="http://blah.com/?test=test&amp;test2=test2">Test1&amp;</a> <a href="http://blah.com/?test=test&amp;amp;test2=test2">Test2&amp;amp;</a> This results in the following HTML Code:
4
3229
by: johkar | last post by:
When the output method is set to xml, even though I have CDATA around my JavaScript, the operaters of && and < are converted to XML character entities which causes errors in my JavaScript. I know that I could externalize my JavaScript, but that will not be practical throughout this application. Is there any way to get around this issue? Xalan processor. Stripped down stylesheet below along with XHTML output. <?xml version='1.0'?>...
8
2818
by: Nathan Sokalski | last post by:
I add a JavaScript event handler to some of my Webcontrols using the Attributes.Add() method as follows: Dim jscode as String = "return (event.keyCode>=65&&event.keyCode<=90);" TextBox2.Attributes.Add("onKeyPress", jscode) You will notice that jscode contains the JavaScript Logical And operator (&&). However, ASP.NET renders this as &amp;&amp; in the code that is
11
6445
by: Jeremy | last post by:
How can one stop a browser from converting &amp; to & ? We have a textarea in our system wehre a user can type in some html code and have it saved to the database. When the data is retireved and
14
5935
by: Arne | last post by:
A lot of Firefox users I know, says they have problems with validation where the ampersand sign has to be written as &amp; to be valid. I don't have Firefox my self and don't wont to install it only because of this, so I hope some of you gurus can enlighten me with this :) In what circumstances can the "&amp;" in the source code be involuntary changed to "&" by a browser when or other software, when editing and uploading the file to the web...
12
10118
by: InvalidLastName | last post by:
We have been used XslTransform. .NET 1.1, for transform XML document, Dataset with xsl to HTML. Some of these html contents contain javascript and links. For example: // javascript if (a &gt; b) ..... // xsl contents abc.aspx?p1=v1&amp;p2=<xsl:value-of select="$v2" />
7
4628
by: John Nagle | last post by:
I've been parsing existing HTML with BeautifulSoup, and occasionally hit content which has something like "Design & Advertising", that is, an "&" instead of an "&amp;". Is there some way I can get BeautifulSoup to clean those up? There are various parsing options related to "&" handling, but none of them seem to do quite the right thing. If I write the BeautifulSoup parse tree back out with "prettify", the loose "&" is still in there. So...
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10091
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9950
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7499
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6739
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2879
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.