Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save gmatta01/a8a0495ca89dd639a91e404d1de71c70 to your computer and use it in GitHub Desktop.
Save gmatta01/a8a0495ca89dd639a91e404d1de71c70 to your computer and use it in GitHub Desktop.
PHP: A snippet for setting the default timezone using a GMT offset.
// Set the default timezone using a GMT offset
$offset = -5; // GMT offset
$is_DST = FALSE; // observing daylight savings?
$timezone_name = timezone_name_from_abbr('', $offset * 3600, $is_DST); // e.g. "America/New_York"
date_default_timezone_set($timezone_name);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment