Ever wanted to know the number of days that have been passed since the beginning of this 2010 and the number of days passed since your birthday ?
Then try this code:
<?php
function noofdays($day_1,$day_2) {
$diff = strtotime($day_2) - strtotime($day_1) + 1; //Find the number of seconds
$day_difference = ceil($diff / (60*60*24)) ; //Find how many days that is
return $day_difference;
}
$bday='1985-06-18'; // My birthday, replace it with yours'
$day1=date("Y-01-01"); // Start date of current year
$day2=date("Y-m-d"); // Today's date
//$diff = strtotime($day2) - strtotime($day1) + 1; //Find the number of seconds
//echo ceil($diff / (60*60*24)) ; //Find how many days that is
$x= noofdays($day1,$day2);
$y= noofdays($bday,$day2);
echo 'No of days passed this year = '.$x;
echo '<br>';
echo 'No of days passed from my birthday till date = '.$y;
?>
Then try this code:
<?php
function noofdays($day_1,$day_2) {
$diff = strtotime($day_2) - strtotime($day_1) + 1; //Find the number of seconds
$day_difference = ceil($diff / (60*60*24)) ; //Find how many days that is
return $day_difference;
}
$bday='1985-06-18'; // My birthday, replace it with yours'
$day1=date("Y-01-01"); // Start date of current year
$day2=date("Y-m-d"); // Today's date
//$diff = strtotime($day2) - strtotime($day1) + 1; //Find the number of seconds
//echo ceil($diff / (60*60*24)) ; //Find how many days that is
$x= noofdays($day1,$day2);
$y= noofdays($bday,$day2);
echo 'No of days passed this year = '.$x;
echo '<br>';
echo 'No of days passed from my birthday till date = '.$y;
?>
Comments
Post a Comment