Im trying to work out how many days old is a date in my database.
For example with this date:
$postdate = '2013-12-19';
I want it to work out that it is 1 day old. If it is todays date then it should be 0.
How can i do this in PHP?
Thanks
Im trying to work out how many days old is a date in my database.
For example with this date:
$postdate = '2013-12-19';
I want it to work out that it is 1 day old. If it is todays date then it should be 0.
How can i do this in PHP?
Thanks
<?php
$a = new \DateTime('2013-12-19');
$b = new \DateTime;
echo $a->diff($b)->days; // => 1