计算我的生日

calculate the day of my Birtday

我如何使用 php 计算我的生日是哪一天,比如星期一、星期二等等..

这里的代码可能需要一些调整,但它应该可以工作。 这是我如何计算出来的link: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);
$age = (date("md", date("U", mktime(0, 0, 0, $year, $month, $day))) > date("md") ? ((date("Y")-$year)-1):(date("Y")-$year));