函数名:strftime()
适用版本:所有版本
用法:strftime() 函数根据区域设置格式化本地时间/日期。
语法:strftime(format, timestamp)
参数:
format:必需。规定时间/日期的格式。可以使用的格式化字符有很多,如下所示:
timestamp:可选。规定时间戳。默认为当前时间。
返回值:返回格式化后的字符串。
示例:
// 格式化当前时间为 "2022-01-01 12:30:00"
echo strftime("%Y-%m-%d %H:%M:%S");
// 格式化指定时间戳为 "Saturday, January 1, 2022"
echo strftime("%A, %B %d, %Y", strtotime("2022-01-01"));
// 格式化当前时间为 "Jan"
echo strftime("%b");
// 格式化当前时间为 "2022-01-01"
echo strftime("%F");
注意事项: