how to compare date and time

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
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

how to compare date and time

Post by itsmani1 »

Code: Select all

$year = "2005"; //Year
$month = "06"; //Month
$day = "29"; //Day
now what i want is just to comapre the above given date with todays date and get the difference in days?
any help plz.
ropson
Forum Newbie
Posts: 2
Joined: Fri May 27, 2005 9:36 am

Post by ropson »

Code: Select all

$year = "2005"; //Year
$month = "06"; //Month
$day = "29"; //Day
$yourDate=$year.'-'.$month.'-'.$day;
$today=date('Y-m-d');
$days=(strtotime($yourDate)-strtotime($today))/86400;
echo $days;
Post Reply