php中知道具体的日期。怎么转换成一年中第多少天。例如2011-1-1是2011年的第一天

如题所述

$firstDay = strtotime('2011-01-01'); //一年的第一天
$now = strtotime('2011-04-27'); //具体日期
echo $diff = ($now-$firstDay)/86400; //第几天:(具体日期时间戳-第一天日期时间戳)/一天
温馨提示:答案为网友推荐,仅供参考
第1个回答  2011-04-28
date函数的参数'z' 。返回值从0-366
date ( 时间格式 , 时间戳) , strtotime 把日期格式,转换成unix时间戳
例如:
echo date('z',strtotime("2011-1-1")); //返回 0
echo date('z',strtotime("2011-1-2")); //返回 1本回答被提问者采纳
相似回答