note 109262 deleted from datetime.gettimestamp by googleguy
| From: | googleguy@php.net | Date: | Tue, 23 Oct 2012 13:30:51 +0000 |
| Subject: | note 109262 deleted from datetime.gettimestamp by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-191498@lists.php.net to get a copy of this message | ||
Note Submitter: ecvej
----
I find that format('U') is circa twice as fast as gettimestamp
<?php
$now = new DateTime('now');
$start = microtime(true);
for ($i = 1; $i <= 10000; $i++)
{
$now->getTimestamp();
}
echo "done in " . (microtime(true) - $start) . "<br/>";
$start = microtime(true);
for ($i = 1; $i <= 10000; $i++)
{
$now->format('U');
}
echo "done in " . (microtime(true) - $start) . "<br/>";
?>
done in 0.067538022994995
done in 0.033107042312622