首页 > 解决方案 > 将php中的日期格式从字符串格式更改为PHP中的另一种格式

问题描述

我需要将 php 中的日期格式从 1/11/2020(字符串格式)更改为 2020-11-01

提前致谢

问候, 萨蒂什

标签: phpdate

解决方案


<?    
$date = "1/11/2020";   
$date = str_replace('/', '-', $date );
$sorted = date("Y-n-d", strtotime($date));

If you only need it to be presented that way and not actually changing the date stored, you can try using printf() as well


推荐阅读