Skip to content

Instantly share code, notes, and snippets.

@shouhei
Created February 13, 2014 06:31
Show Gist options
  • Save shouhei/8970792 to your computer and use it in GitHub Desktop.
Save shouhei/8970792 to your computer and use it in GitHub Desktop.
PHP setting timezone example
<?php
$date_utc = new DateTime();
$date_utc->setTimezone( new DateTimezone('UTC') );
echo preg_replace("/\+/"," +",preg_replace("/T/"," ",$date_utc->format(DATE_ISO8601))).PHP_EOL;
$date = new DateTime();
$date->setTimezone( new DateTimezone('Asia/Tokyo') );
echo preg_replace("/\+/"," +",preg_replace("/T/"," ",$date->format(DATE_ISO8601))).PHP_EOL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment