我需要将年份(YY)转换为 YYYY。在这里,我尝试使用datePHP 中的函数,但没有得到预期的结果。
$expiry_year = "30"; //year=2030
echo date('Y',strtotime($expiry_year)); //Result: 1970
echo date('Y',$expiry_year); //Result: 1970
Run Code Online (Sandbox Code Playgroud)
预期结果:2030年
谢谢大家!
试试这个,使用 createFromFormat
$date = "30";
$dates = DateTime::createFromFormat('y', $date);
//now to get the outpu:
$arr = $dates->format('Y'); // output : 2030
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3895 次 |
| 最近记录: |