[Edit: I saw later that the DateTime ticks are also very similar to the PHP DateTime-> diff method, so I added it; realized that I missed the parameter for microtime, thanks to freedom of speech.]
I usually do this for benchmarking (kudo also for freedom of speech):
$time = microtime(true); // do your thing $diff = microtime(true) - $time;
See: http://php.net/microtime
On other dates, you can do it like this:
$date1 = new DateTime('05-04-2010'); $date2= new DateTime('yesterday');
The DateInterval object has the following topology:
public integer $ DateInterval-> y;
public integer $ m;
public integer $ d;
public integer $ h;
public integer $ i;
public integer $ s;
public integer $ invert;
public mixed $ days;
DateTime Class http://www.php.net/manual/en/class.datetime.php
Diff Method http://www.php.net/manual/en/datetime.diff.php
DateInterval Object http://www.php.net/manual/en/class.dateinterval.php
Arend source share