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
m2babaey
Forum Contributor
Posts: 364
Joined: Sun May 20, 2007 9:26 am

date

Post by m2babaey »

Hi
I want to calcaulate how many, days is between 2010-1-10 and 1999-11-1
Ho can i do that?
miro_igov
Forum Contributor
Posts: 485
Joined: Fri Mar 31, 2006 5:06 am
Location: Bulgaria

Post by miro_igov »

Code: Select all

$from = strtotime('1999-11-1');
$to = strtotime('2010-1-10');

$seconds = $to - $from;

$days = $seconds / 60*60*24;

echo $days;
This will not work for dates before 1970.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

We've had several topics on this recently. There's also a Code Snippet about this. What results have you found from searching?
Post Reply