Php has two way to do date manipulation. That is DateTime object and date function. What is the best way to do? What is the way is fastest? Are they have different? I think DateTime wast memory to create a object and have to write more code.
e.g -
get current date
$do = new DateTime('now'); print $do->format('Y-m-d H:i:s');
or
print date('Y-m-d H:i:s');
compair the time
$datetime1 = new DateTime('2009-10-11'); $datetime2 = new DateTime('2009-10-13'); $interval = $datetime1->diff($datetime2); echo $interval->format('%R%a days');
or
$datetime1 = new DateTime('2009-10-11');
$datetime2 = new DateTime('2009-10-13');
$interval = $datetime1->diff($datetime2);
echo $interval->format('%R%a days');