我可以像一样在PHP
中为日期添加年份
$yr = '2020-03-28';
$dt = date('d.m.Y', strtotime('+2 years'));
//Output 28.03.2022
如何在PHP
中添加十进制年份?我想做一些类似的事情
$yr = '2020-03-28';
$dt = date('d.m.Y', strtotime('+1.25 years'));
//Output 01.01.1970
感谢
将其乘以365,四舍五入到最接近的整数,然后加上天数,例如:
$years = 1.25;
$days = floor( $years * 365 ); // Note: not accurate for leap years!
$dt = date('d.m.Y', strtotime("+$days days"));