为了账号安全,请及时绑定邮箱和手机立即绑定

如何在php中将Sun 10-04-19日期转换为10-04-2019

如何在php中将Sun 10-04-19日期转换为10-04-2019

PHP
慕莱坞森 2021-06-29 09:58:54
如何将 php Sun 10-04-19 中的日期格式更改为 10-04-2019 请帮忙,谢谢,这是我的代码    $content1="Sun 10-04-19";     $newformat = strtotime($content1);    echo date('d-m-Y',$newformat);输出  25-04-2010
查看完整描述

1 回答

?
噜噜哒

TA贡献1784条经验 获得超7个赞

您可以使用DateTime并指定日期格式

$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


查看完整回答
反对 回复 2021-07-09
  • 1 回答
  • 0 关注
  • 174 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信