[ create a new paste ] login | about

Link: http://codepad.org/DVFrKgFk    [ raw code | output | fork ]

PHP, pasted on Mar 2:

// Player A creates match at 1PM Europe/London
$timezone = 'Europe/London';
$localTime = '2012-03-01 13:00:00';

// set the user preference

// strtotime parses the time string as London time
$timestamp = strtotime($localTime);

// store $timestamp in the database, which is irrespective of timezone

// -------------------------------------

// Player B views the timestamp with timezone America/Los_Angeles
$timezone = 'America/Los_Angeles';

// set the timezone so all date output uses the user's preference

// date format uses the preference set in the previous line to affect its output
var_dump(date('c', $timestamp)); // see manual for more output formats

string(25) "2012-03-01T05:00:00-08:00"

Create a new paste based on this one