Skip to content

Instantly share code, notes, and snippets.

@scottalan
Forked from glennpratt/gist:1016744
Created June 13, 2011 14:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scottalan/1022898 to your computer and use it in GitHub Desktop.
Save scottalan/1022898 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