0

I am developing a recruitment website where our clients (employers) can "reserve" candidates (potential employees) for 7 days, so that the candidate that Client A is interested in doesn't appear in search results (candidates are automatically released after 7 days but clients can also manually release them back into the system). When Client A views a list of candidates he/she has reserved, each record contains basic information for each candidate, including the date and time that he/she was reserved and will be released (i.e. be made available for searches by all clients).

That part is easy. The problem comes in when I want to localise this date and time, based on which subdomain the client is using. We have two branches in two different countries, in two different time zones, in two different hemispheres on two different time systems (one is based in the UK, which uses daylight savings time, while the other is in South Africa, which does not). Added to this, there are plans in place to open other branches in other countries, which will, no doubt, compound the problem further down the line.

I could adjust the timestamp (I'm using time() to set the dates) using:

$domExplode = explode('.', $_SERVER['HTTP_HOST']);
$subdom = $domExplode[0];

switch($subdom) {
  case "uk":
    $timeadjust = 0;
  break;
  case "za":
    $timeadjust = 2*60*60;
  break;
  default:
    $timeadjust = 0; //Head Office is in South Africa so GMT+2 is the standard.
  break;
}

$datereserved = $row_rescand['resdte'] + $timeadjust;
$releasedate  = $row_rescand['reldte'] + $timeadjust;

but this doesn't account for daylight savings time. Also, it means I will have to manually update the code each time we add a new country. Is there a better way of doing this, preferably something that will automate the process, perhaps by using the MySQL database entry I have for each country?

Terms and conditions of using the site is that cookies and javascript have to be allowed so I am open to either a PHP or JS/JQuery solution. I am just coming up blank.

Thanks in advance.

  • Have you tried using any of the built-in Date/Time functionality with timezone settings? – deceze Apr 09 '13 at 22:54
  • 2
    This resource should help you get the end-users timezone: http://stackoverflow.com/questions/1905397/how-to-get-clients-timezone – Joban Apr 09 '13 at 23:00

0 Answers0