Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8649667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:37:04+00:00 2026-06-12T13:37:04+00:00

Let’s say I have a PHP script that does this: $timeNow = 1349852400000; //

  • 0

Let’s say I have a PHP script that does this:

$timeNow = 1349852400000; // Unix time for Oct 10, 2012 00:00:00 PDT
echo "<script type='text/javascript'>";
echo     "setTimeout(function(){alert('time out!');}, $timeNow - Date.now());";
echo "</script>";

What if this script is served to a device whose date/time are set to 2013. What will happen? What if this is served to a device whose date/time are set to 2010?

Does it matter what time and date the server’s clock is set to? How does that affect the device in 2013? What about the one stuck in 2010?

If I wanted to choose a value for $timeNow that will throw the alert at the moment everywhere synced on October 10, 2012 at 00:00:00 for San Francisco, CA (that is, a device that’s set to Pacific time and a device set to Central time should display the alert at the same moment even though it will be 2:00:00 AM for the Central time device), could I do it? Won’t I have to serve one value to the Pacific device and a different one for the Central device to account for the time zone difference from UTC?

Sorry, time zones are really confusing for me. I’m having trouble wrapping my head around them.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T13:37:05+00:00Added an answer on June 12, 2026 at 1:37 pm

    You don’t have anything to worry about if you use Unix time for this (with one exception below). It sounds like you want the alert to pop up all over the world at the exact same instant no matter the timezone.

    Unix time 0 is

    • January 1, 1970, midnight, Zulu time
    • December 31, 1969, 4:00pm, San Francisco time

    So if you arranged for an alert to go off at time 0, people in San Francisco and London would see the alert at the same time. Ditto for any Unix time, which is really just a number that describes an instant in time. The same instant everywhere in the world. So both of the following datetime strings

    • 1970-01-01T00:00:00Z
    • 1969-12-31T16:00:00-0800

    are representations of the same instant, denoted by Unix time 0.

    Similarly everyone in the world sees the time 1349852400000 at the exact same instant, regardless of their time zone. So since your code is trying to alert something at a given instant described by a Unix time, your code in principle should work, provided the computers on which the script is running are set to the correct time.

    I suppose if you really want to have a bunch of computers all alert something at the same time (are you writing a virus? Just kidding) and you want to handle the case where the devices may have improperly set clocks, you can have them make calls to a central time server and set your timeout based on that. Then you will probably have to deal with cross-site issues, but in principle, if all the machines agree to talk to and accept data from a central time server, you can do this.

    ADDENDUM

    Here is how that might work. Let’s say your script is running on a bunch of machines. They all have their clocks all set wrong. Maybe they set their clocks wrong on purpose; maybe they set their clocks wrong accidentally. But you want them all to alert at the same time.

    So what your script should do is this: make an (Ajax) call to your server — the same server that delivered the HTML page in which the script is embedded, to simplify cross-site issues. This call talks to your server, which knows the real time. Now you also know the time from now until the alert time. So substract those two values on your server and deliver back to the clients that number. Then the clients do

    setTimeout(theAlertFunction, theValueReturnedFromTheAjaxCall)
    

    and you are good to go.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say you have a string that looks like this: token1 token2 tok3 And
Let me explain best with an example. Say you have node class that can
Let's say that I have a SQLite database that I create in a separate
Let's say I have a sortable list like this: $(.song-list).sortable({ handle : '.pos_handle', axis
Let's say I have a string like this: var str = /abcd/efgh/ijkl/xxx-1/xxx-2; How do
Let's say on a page I have alot of this repeated: <div class=entry> <h4>Magic:</h4>
Let's say I have a text file composed like this ##### typeofthread1 ##### typeofthread2
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Let's say I have this code: <p dataname=description> Hello this is a description. <a
Let's say I have multiple requirements for a password. The first is that the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.