Php 计算一年的时间戳
考虑到我有Php 计算一年的时间戳,php,Php,考虑到我有$num\u years,我如何将它添加到Time()中,以获得时间戳$num\u years echo strtotime("now + $num_years years"); 这就是你想要的吗 $num_years = 5; $future = strtotime("+{$num_years} years"); 这是你想要的吗 //Example to add 1 year to a date object $num_years = 1; $currentDate = dat
$num\u years
,我如何将它添加到Time()
中,以获得时间戳$num\u years
echo strtotime("now + $num_years years");
这就是你想要的吗
$num_years = 5;
$future = strtotime("+{$num_years} years");
这是你想要的吗
//Example to add 1 year to a date object
$num_years = 1;
$currentDate = date("Y-m-d");// current date
//Display the current date
echo "Current Date: ".$currentDate."<br>";
//Add one year to current date
$dateOneYearAdded = strtotime(date("Y-m-d", strtotime($currentDate)) . " +$num_years years");
echo "Date After adding one year: ".date('l dS \o\f F Y', $dateOneYearAdded)."<br>";
//向日期对象添加1年的示例
$num_years=1;
$currentDate=日期(“Y-m-d”);//当前日期
//显示当前日期
回显“当前日期:.$currentDate.”
“;
//将一年添加到当前日期
$dateOneYearAdded=strotime(日期(“Y-m-d”,strotime($currentDate))。“+num_年”);
echo“添加一年后的日期:”.Date('ld\o\f f Y',$dateOneYearAdded)。“
”;
strotime(“+$num\u年”)
将为您提供一个时间戳$num\u年
年
echo strftime('%Y %a %d %m, %T', strtotime('+' . $num_years . ' years') );
根据您的需要更改strftime格式。
查看strotime手册页如果您正在查找该时间的时间戳,请使用
mktime
mktime(0,0,0,0,0,$noOfYears);
这难道不会让你在1月1日00:00返回数年吗?如果今天是12月1日,我再加上两年,我想看到2012年12月1日