Skip to content

Instantly share code, notes, and snippets.

@jlittlejohn
Created May 31, 2013 14:30
Show Gist options
  • Save jlittlejohn/5685365 to your computer and use it in GitHub Desktop.
Save jlittlejohn/5685365 to your computer and use it in GitHub Desktop.
PHP: DateTime Class
<?php
/* Get server time */
$date = new DateTime();
echo $date->format('Y-m-d H:i:s');
/* Add 1 Day */
$date->add(new DateInterval('P1D'));
echo '<br>'.$date->format('Y-m-d H:i:s');
/* Change Timezone to UTC */
$date->setTimezone(new DateTimeZone('etc/UTC'));
echo '<br>'.$date->format('Y-m-d H:i:s');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment