温馨提示×

php strtotime函数支持多种格式吗

PHP
小樊
86
2024-12-06 19:36:15
栏目: 编程语言
PHP开发者专用服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

是的,PHP 的 strtotime() 函数支持多种格式。它可以解析多种日期和时间格式,并将其转换为 Unix 时间戳。以下是一些常用的日期和时间格式:

  1. “Y-m-d” - 年-月-日 (例如: “2022-08-15”)
  2. “d-m-Y” - 日-月-年 (例如: “15-08-2022”)
  3. “m/d/Y” - 月/日/年 (例如: “08/15/2022”)
  4. “d M Y” - 日 月 年 (例如: “15 Aug 2022”)
  5. “Y-m-d H:i:s” - 年-月-日 时:分:秒 (例如: “2022-08-15 14:30:00”)
  6. “d-m-Y H:i:s” - 日-月-年 时:分:秒 (例如: “15-08-2022 14:30:00”)
  7. “m/d/Y H:i:s” - 月/日/年 时:分:秒 (例如: “08/15/2022 14:30:00”)

strtotime() 函数还支持一些额外的格式选项,如时区、星期几等。要了解更多关于 strtotime() 函数的信息,你可以查阅 PHP 官方文档:https://www.php.net/manual/en/function.strtotime.php

亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

推荐阅读:php strtotime函数用法

0