calculate the day of my Birtday

70 views Asked by At

how i calculate that on what day my Birthday Comes Using php like on Monday, Tuesday and so on..

2

There are 2 answers

11
Sari Rahal On BEST ANSWER

Here this code might need some tweaking but it should work. And here is a link of how I figured it out: http://php.net/manual/en/function.date.php

//create a date of John
$birth_date =  mktime(0,0,0,1,6,1991);
//determine if John's birthday has passed this year
if (date("m",$birth_date) > date("m") 
   && (date("d",$birth_date) > date("d"))){
       $year = date("Y");  
}else {
       $year = date("Y")+1;
} 
//find his next birthday
$next_birth_date = mktime(0,0,0,
     date("m",$birth_date),
     date("d",$birth_date),
     $year);
//echo the day of his next birthday
echo date('l', $next_birth_date);
1
Circum On
$age = (date("md", date("U", mktime(0, 0, 0, $year, $month, $day))) > date("md") ? ((date("Y")-$year)-1):(date("Y")-$year));