Skip to content

Instantly share code, notes, and snippets.

@Quilted
Created November 15, 2013 17:04
Show Gist options
  • Save Quilted/7487840 to your computer and use it in GitHub Desktop.
Save Quilted/7487840 to your computer and use it in GitHub Desktop.
Drupal 7 dates with proper timezone handling
<?php
// Assumes date field is $variables['field_event_date']
$dateObj = new DateObject($variables['field_event_date'][0]['value'], new DateTimeZone($variables['field_event_date'][0]['timezone_db']));
$dateObj->setTimezone(new DateTimeZone($variables['field_event_date'][0]['timezone']));
$date = $dateObj->getTimestamp();
@Quilted
Copy link
Author

Quilted commented Nov 15, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment