Intermedio

Deal with converting to correct timezone in php and drupal 7

<?php

// Title: Convert to correct timezone.

// Set default time.

$date = new DateTime('2018-05-17 22:29:00', new DateTimeZone('UTC'));

print $date->format('Y-m-d H:i:s') . "\n"; // 2018-05-17 22:29:00

// Now convert to correct timestamp.

$date->setTimezone(new DateTimeZone('Australia/Brisbane'));

print $date->format('Y-m-d H:i:s') . "\n"; // 2018-05-18 08:29:00

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

Suscribirse a Intermedio