Get Answers!
   

Diesel

How Can I Show The Difference Between Two Dates Using PHP?

Tuesday, 21st October 2008

I need to display this as: x minutes ago x hours ago x days ago
 





Jess
Hi,
This should be just the script you are looking for:

<?php
$date1=time();
$date2=strtotime($pastdate)

$dateDiff = $date1 - $date2;
$fullDays = floor($dateDiff/(60*60*24));
$fullHours = floor(($dateDiff-($fullDays*60*60*24))/(60*60));
$fullMinutes = floor(($dateDiff-($fullDays*60*60*24)-($fullHours*60*60))/60);
echo "Differernce is $fullDays days, $fullHours hours and $fullMinutes minutes.";
?>
Wednesday, 22nd October 2008
Votes:

More Programming:
» How can I add a Google Site Search box to my web site?
» How Do I Upload A Sitemap.xml File To My Google Site? What Program Do I Use To Do It?
» Which PHP Ad Manager Do You Recommend For Me To Use?
» Php Tutorial Neded
» How To Split A String
» How Can I Print In PHP?
» How Can I Creat A Flash Poll
» Which Is The Best PHP Content Management System?


Leave a Comment on "How Can I Show The Difference Between Two Dates Using PHP?"
You must be logged in to post a comment.


Link to This Question!