如何在php中更改日期格式 周日10/10/19至2019/10/04 请帮助,谢谢你,
这是我的代码
$content1="Sun 10-04-19";
$newformat = strtotime($content1);
echo date('d-m-Y',$newformat);
输出
25-04-2010
答案 0 :(得分:2)
您可以使用DateTime并指定date format来完成此操作:
$content1 = "Sun 14-04-19";
// assuming the format is day-month-year
$newformat = DateTime::createFromFormat('D d-m-y', $content1);
echo $newformat->format('d-m-Y');
您的日期无效。
结果:
14-04-2019