public function testTimezoneFromFormSubmission() { $oldTz = date_default_timezone_get(); date_default_timezone_set('Europe/Berlin'); // Berlin and Auckland have 12h time difference in northern hemisphere summer, but Berlin and Moscow only 2h. $f = new DatetimeField('Datetime', 'Datetime'); $f->setConfig('usertimezone', 'Pacific/Auckland'); // should be overridden by form submission $f->setValue(array('date' => '24/06/2003', 'time' => '23:59:59', 'timezone' => 'Europe/Moscow')); $this->assertEquals('24/06/2003 23:59:59', $f->Value(), 'View composite value matches user timezone'); $this->assertEquals('24/06/2003', $f->getDateField()->Value(), 'View date part matches user timezone'); $this->assertEquals('23:59:59', $f->getTimeField()->Value(), 'View time part matches user timezone'); // 2h difference to Moscow $this->assertEquals('2003-06-24 21:59:59', $f->dataValue(), 'Data value matches server timezone'); date_default_timezone_set($oldTz); }