php - 将php中的日期格式从字符串格式更改为PHP中的另一种格式
问题描述
我需要将 php 中的日期格式从 1/11/2020(字符串格式)更改为 2020-11-01
提前致谢
问候, 萨蒂什
解决方案
<?
$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
推荐阅读
- vue.js - 为什么 Vue .splice() 总是删除最后一项
- excel - 有没有办法在 VBA 中对 Outlook 电子邮件的主题行进行编码,以对应于从不同单元格中提取的多个部分?
- python - Django 2.2 - 上下文处理器无法使全局变量在模板中可用
- yum - CentOS8 手动安装时无法 yum 更新,但浏览器已连接互联网
- php - 我怎样才能使这个功能更简单?未知的阵列深度
- erlang - Erlang 的 mod_esi 可以重定向吗?
- powershell - 通过 powershell 或 appcmd 将应用程序池设置为在多个特定时间回收不会在 GUI/IIS 中显示两次
- html - 使用 FlexBox 约束一半的页面内容
- android - 如何处理“无法启动活动 java.util.ConcurrentModificationException”
- vim - VS Code Vim 模式(在光标下打开文件)