Aug
22
Drupal: Zeitzone UTC zu Europe/Paris konvertieren
Montag, 22. August 2011 10:37
Modul: Date
Aufbau des Felds vom Typ Datum:
print_r($node->field_date);
Output:
Array ( [de] => Array ( [0] => Array ( [value] => 2011-10-25T18:00:00 [timezone] => Europe/Paris [timezone_db] => UTC [date_type] => date ) ) )
In der Datenbank wird der Datumswert in diesem Beispiel im UTC-Format abgespeichert, welchen wir nun in der gewünschten Zeitzone Europe/Paris konvertieren:
$date_timezone_db = $node->field_date['de'][0]['timezone_db']; $date_timezone = $node->date['de'][0]['timezone']; $date_value = $node->date['de'][0]['value']; $date = new DateObject($date_value, $date_timezone_db); $date->setTimezone(timezone_open($date_timezone)); $formatted_date = $date->format('d.m.Y H:i:s'); echo $formatted_date; // output: 25.10.2011 20:00:00
Thema: Drupal, Webentwicklung | Kommentare (0) | Autor: gutman





