Get time since given date

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Clukey
Forum Commoner
Posts: 60
Joined: Fri Apr 21, 2006 9:05 pm

Get time since given date

Post by Clukey »

I am trying to find the amount of time that has passed since a given date (retrieved from a database), but I'm quite new to PHP date functions. I found this:

Code: Select all

$dateSrc = $info['creationdate'];
$dateTime = new DateTime($dateSrc);
The date will be formatted like this: "15:30:14 Oct 16, 2007 PDT"

Where do I go from here?

Thanks.
Clukey
Forum Commoner
Posts: 60
Joined: Fri Apr 21, 2006 9:05 pm

Post by Clukey »

I figured it out:

Code: Select all

$created = strtotime($info['creationdate']);
$now = strtotime("now");
$difference = $now-$created;
gets difference in seconds
Post Reply