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

  • SEARCH
  • Home
  • 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 8698493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:44:34+00:00 2026-06-13T01:44:34+00:00

I’ve been searching alot and I can’t seem to find a solution. I have

  • 0

I’ve been searching alot and I can’t seem to find a solution.

I have a PHP web page where I can schedule email alerts at specific times. I select the date and time of when the alert is to be sent. This is stored in MySQL table in UNIX format. I have a job that executes every 15 minutes and sends the emails if the date+time is in the past – this all works perfectly except I need to extend it for my USA colleagues. I am based in Ireland so I will need to manage the different timezones all across the US. I am planning on adding a select list of timezones that the user will have to select once they register…at least thats a start. Managing timezones is fine because I reckon all I need to do is minus the time different from the server time and then save the date time in unix format. DST is a different issue tho – does anyone have any ideas on how to overcome this?

I have read that using UTC as the base time but even if that is the case wont I still have the same issue?

Thanks a mil!

  • 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-13T01:44:34+00:00Added an answer on June 13, 2026 at 1:44 am

    Your times are already in UNIX timestamp format so all you need is to calculate time difference (offset) of user. For example Ireland is in UTC/UTC+1 timezone. So all you need is to do the math like james_t mentioned in his comment. If you need user from Ireland to get an email in 9:00pm UTC+1 you have to send it in 8:00pm UTC. So what’s an idea?

    Allow users to select timezone which means they select offset from UTC. Keep it somewhere in database (your users table or some other table, doesn’t matter).

    Convert offset in seconds:

    $delta_time = -1 * $offset * 3600
    

    Then calculate your trigger-time:

    $trigger_time = time() + $delta_time;
    

    Now you have time when your email sender can fire in right moment depending on user’s timezone settings.

    For example:

    $offset = 1; // summer in Ireland
    $server_time = time(); // at the moment 1350509127
    $delta_time = -1 * $offset * 3600; // -3600
    $trigger_time = $server_time + $delta_time; // 1350505527
    

    All you need is to compare $trigger_time with UNIX timestamp from your database and decide to send an email (or not).

    Ofc, it’s not bad idea to use PHP timezones instead of pure +/- offset and stay updated when DST changes apply on certain locations.

    Make some test, this is not that hard.

    This is just a general idea, not complete working solution.

    Update:

    To calculate time-difference in seconds between any two timezones you can use something like this:

    function delta_offset()

      function delta_offset($server_timezone, $user_timezone) {
        $dt = new DateTime('now', new DateTimeZone($server_timezone));
        $offset_server = $dt->getOffset();
        $dt->setTimezone(new DateTimeZone($user_timezone));
        $offset_user = $dt->getOffset();
        return $offset_user - $offset_server;
        }
    

    To get an offset in seconds:

      $server_tz = "Europe/London";
      $user_tz = "America/New_York";
      $offset = delta_offset($server_tz, $user_tz);  // offset in sec.
    

    Create some output:

      $dt = new DateTime('now', new DateTimeZone('UTC'));
      echo "<pre>UTC date/time: " . $dt->format('l, F jS, <b>H:i:s</b>') . "\n";
      $dt = new DateTime('now', new DateTimeZone($server_tz));
      echo "London date/time: " . $dt->format('l, F jS, <b>H:i:s</b>') . "\n";
      $dt = new DateTime('now', new DateTimeZone($user_tz));
      echo "New York date/time: " . $dt->format('l, F jS, <b>H:i:s</b>') . "\n\n";
      echo "Time difference between London (UK) and New York (USA) is: <b>$offset_h</b> ($offset s)</pre>";  
    

    Output in browser (in moment of writing this post):

    UTC date/time: Wednesday, October 17th, 22:32:27
    London date/time: Wednesday, October 17th, 23:32:27
    New York date/time: Wednesday, October 17th, 18:32:27
    
    Time difference between London (UK) and New York (USA) is: -5:00 (-18000 s)
    

    In this case offset is -5 hours (-18000 seconds) but it automatically changes if DST rules change for any of timezones given as function-arguments.

    Delta-offset provides information how much earlier or later you have to send an email to user in different timezone and all you need now is to do simple +/- delta-offset with your email-sender’s scheduler.

    Hope this may help you to get right solution for your problem.

    Update #2 – Example (theory)

    Imagine this situation.

    Your current server-time is X and its 7:00pm at the moment in Ireland. I live in Serbia and we have same DST rules but I’m one hour after (UTC+1/UTC+2). Difference between your and my time is +3600 seconds (1 hour).

    Now you have to send an email to me in 10:00pm (it’s 9:00pm in Ireland).

    • Current time is X.
    • Delta-offset is -1 * +3600 = -3600 (delta-offset multiplied with -1).
    • Sending time on your location in 10:00 pm is X + 10800 (3 hours later).
    • Sending time on my location in 10 pm is X + 10800 + delta-offset = X + 7200 (2 hours later).

    Formula to check if actual time is equal or greater than trigger-time (sending time) is:

    current_timestamp >= trigger_timestamp + delta_offset
    

    where delta-offset from delta_offset() function must be multiplied with -1 to use in formula.

    Now you can send email when you want and be sure it will be sent using user’s local time (ofc, if user timezone settings are correct).

    Note: Difference from this example (Serbia – Ireland = +1 hour) is different during DST changes which means that 1 hour every year we’re in same timezone (0 delta-offset), and one hour we have +2 hours delta-offset. This is possible because DST changes are applied 1 hour earlier in Serbia so when our time is changed +1 you have to wait 60 minutes before same change applies to Ireland-time *then we’re +2) and same thing when we bring back clock to normal time (0 difference).

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

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
That's pretty much it. I'm using Nokogiri to scrape a web page what has
this is what i have right now Drawing an RSS feed into the php,
Seemingly simple, but I cannot find anything relevant on the web. What is the
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

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.