交互式参考:测试格式字符串、查找参数并尝试 strtotime() 表达式。
{{ dateResult }}
<?php echo date("{{ dateFormat }}"); ?>
| {{ __t('th_character') }} | {{ __t('th_description') }} | {{ __t('th_example') }} | |
|---|---|---|---|
| {{ group.title }} | |||
{{ p.char }} |
{{ p.desc }} | {{ getParamExample(p.char) }} | |
{{ strtotimeResult.timestamp }}
{{ strtotimeResult.formatted }}
{{ strtotimeResult.relative }}
{{ strtotimePhpCode }}
| {{ __t('th_expression') }} | {{ __t('th_description') }} | {{ __t('label_result') }} |
|---|---|---|
{{ ref.expr }} |
{{ ref.desc }} | {{ getStrtotimeExample(ref.expr) }} |
函数 date(string $format, ?int $timestamp = null) 将 Unix 时间戳或当前时间格式化为可读字符串。格式字符串由占位符组成,如 Y(四位数年份)、m(带前导零的月份)、d(日)或 H:i:s(24小时制的时:分:秒)。
strtotime(string $datetime, ?int $baseTimestamp = null) 将英文文本描述转换为 Unix 时间戳。典型输入:"now"、"+1 day"、"next monday"、"first day of next month"、"last day of december 2025"。该函数非常灵活,还能理解组合表达式,如 "+2 weeks 3 days"。
date("Y-m-d") — ISO 日期: 2025-03-15date("d.m.Y") — 德语格式: 15.03.2025date("Y-m-d H:i:s") — MySQL Datetimedate("c") — ISO 8601: 2025-03-15T14:30:00+01:00date("r") — RFC 2822: Sat, 15 Mar 2025 14:30:00 +0100date("U") — Unix 时间戳