Ответов: 2 Просмотров: 166
|
andrewkard пишет:не тот пример выдрал
PHP:
скопировать код в буфер обмена
Note that getTimestamp() does not return the UTC timestamp. It returns the timestamp relative to the set timezone, or the default server timezone. This also applies to dates in timezones with Daylight Savings. <?PHP // 11th March 2016 @ 11:00 UTC has timestamp: 1457694000 $d1 = new DateTime('2016-03-11 11:00:00', new DateTimeZone('Europe/Rome')); $t1 = $d1->getTimestamp(); // 11th April 2016 @ 11:00 UTC has timestamp: 1460372400 $d2 = new DateTime('2016-04-11 11:00:00', new DateTimeZone('Europe/Rome')); $t2 = $d2->getTimestamp(); printf("11 March: %d (diff = %d less)\n", $t1, 1457694000 - $t1); printf("11 April: %d (diff = %d less)", $t2, 1460372400 - $t2); // Prints: // 1457690400 (diff = 3600) // 1460365200 (diff = 7200)
Ok, спасибо |