求一php计算时间的程序 求一PHP程序输入出生年、月、日能计算出今天的年龄和出生那天是星期几?? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 $inputdate="????????"echo date("Y")-date("Y",$inputdate);//年龄echo date("w",$inputdate);//星期 $inputdate="1985-2-4";$inputdate_arr=explode("-",$inputdate);echo date("Y")-$inputdate_arr[0];//年龄echo date("w",$inputdate);//星期 <?php$nYear = 2000;$nMouth = 1;$nDay = 12;// 年龄$nAge = intval( date( 'Y' ) ) - $nYear;// 那天星期几$nTimestamp = strtotime( $nYear . "-" . $nMouth . "-" . $nDay );$nWeek = date( 'w', $nTimestamp );?> 上几位请注意,php的时间函数只支持1970以后 是对的啊。我测试的是php5.2.61970以前的是负数,对照万年历,星期也是对的。$inputdate="1965-2-3";$inputdate_arr=explode("-",$inputdate);echo date("Y")-$inputdate_arr[0]."<br>";//年龄45echo date("w",strtotime($inputdate))."<br>";//星期3echo strtotime($inputdate)."<br>";//-154915200 php 中文件上传问题 有做PHP的在读研究生或者SOHO人士吗? PHP如何对字符串进行Base64 编码 php 发送邮件的问题 windows xp 无法安装 apache 无法获取$file=file("seo/$sa.txt"); win7 32位系统下的apache配置ssl的问题 请用php-mysql解决 获取html标签的函数. 关于加载扩展模块 linux下apache mysql php 配置疑问2 计算时间
echo date("Y")-date("Y",$inputdate);//年龄
echo date("w",$inputdate);//星期
$inputdate_arr=explode("-",$inputdate);
echo date("Y")-$inputdate_arr[0];//年龄
echo date("w",$inputdate);//星期
<?php$nYear = 2000;
$nMouth = 1;
$nDay = 12;
// 年龄
$nAge = intval( date( 'Y' ) ) - $nYear;// 那天星期几
$nTimestamp = strtotime( $nYear . "-" . $nMouth . "-" . $nDay );
$nWeek = date( 'w', $nTimestamp );?>
1970以前的是负数,对照万年历,星期也是对的。
$inputdate="1965-2-3";
$inputdate_arr=explode("-",$inputdate);
echo date("Y")-$inputdate_arr[0]."<br>";//年龄45
echo date("w",strtotime($inputdate))."<br>";//星期3
echo strtotime($inputdate)."<br>";//-154915200