rosuandreimihai
rosuandreimihai

Reputation: 656

PHP fixed time relative to GMT time

Using PHP I am trying to send one email to partners from different countries at specific time frame. Let us say that the hour is fixed to 17:00 to each country not to my time frame. So, if I am in London, the 17:00 hours will be different than Australia's 17:00 hours.

How can I check and make sure that for a list of countries the email sent is at the correct 17:00 hours?

Thanks in advance

Upvotes: 0

Views: 113

Answers (1)

AlexL
AlexL

Reputation: 1707

I imagine you're going to use a cronjob. If that's the case you can set the script to run every hour. When the script runs it should check in which timezone/country it's the desired hour. If a timezone/country is found to have the desired hour on that run, select the users from that timezone/country and send your email to them

Code to check time in AU:

$tz1 = new DateTimeZone('GMT');
$tz2 = new DateTimeZone("Australia/Sydney");
$date = new DateTime(null, $tz1);
$date->setTimezone($tz2);
$australia_hour = $date->format("H:i");

Upvotes: 1

Related Questions