Skip to content

Instantly share code, notes, and snippets.

@glennpratt
Created June 9, 2011 13:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save glennpratt/1016744 to your computer and use it in GitHub Desktop.
Save glennpratt/1016744 to your computer and use it in GitHub Desktop.
DateTime.php
$ php -a
Interactive shell
php > $date = new DateTime('now');
php > $timestamp = $date->format('U');
php > var_dump($timestamp);
string(10) "1307626589"
php > $timestamp = $date->getTimestamp();
php > var_dump($timestamp);
int(1307626589)
php > $timestamp = intval($date->format('U'));
php > var_dump($timestamp);
int(1307626589)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment