PHP中将“年月日时分秒”的时间转换成“年月日”的时间格式

函数:

strtotime() 函数可将任何英文文本的日期或时间描述解析为 Unix 时间戳(自 January 1 1970 00:00:00 GMT 起的秒数)。

 

原理:

先将完整的时间格式转换成时间戳的形式,然后再去进行将“年月日时分秒”的时间戳转换成“年月日”的时间格式。

 

用法示例:

<?php
echo date("Y-m-d",strtotime("2021-06-29 16:18:88"));
    A+
发布日期:2021年06月29日 16:14:58  所属分类:PHP
最后更新时间:2021-06-29 23:19:10
付杰
  • ¥ 49.9元
  • 市场价:99.9元
  • ¥ 58.0元
  • 市场价:58.0元
  • ¥ 398.0元
  • 市场价:498.0元
  • ¥ 68.0元
  • 市场价:98.0元

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: