Finding # of Days between two timestamps

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
LiveFree
Forum Contributor
Posts: 258
Joined: Tue Dec 06, 2005 5:34 pm
Location: W-Town

Finding # of Days between two timestamps

Post by LiveFree »

Hello All,

For some reason, I have never been good when it comes to manipulating date information.

So...

I have 2 timestamps:

Code: Select all

<?php
$start = strtotime('SomeDateInthePast');
$end = time();

$time_between = $end - $start;
?>
Now, how would I find the number of days $time_between is.

I've tired dividing it by 60 and then by 24, and multiplying it by 60 and then 24, but nothing works.

Any Thoughts?
Thanks in Advance
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Post by VladSun »

... I've tired dividing it by 60 and then by 24...
You have to divide by another 60 (that's for seconds):

viewtopic.php?t=71617
There are 10 types of people in this world, those who understand binary and those who don't
Post Reply