PHP - 如何使用 $timestamp 检查今天是星期一还是每月 1 号?

phpserver side programmingprogramming更新于 2025/7/22 10:52:17

date 函数可用于返回根据指定格式格式化的字符串,该格式通过提供整数时间戳实现;如果未提供时间戳,则返回当前时间。

时间戳是可选的,默认为 time() 的值。

示例

if(date('j', $timestamp) === '1')
   echo "It is the first day of the month today
"; if(date('D', $timestamp) === 'Mon')    echo "It is Monday today
";

输出

这将产生以下输出 −

It is the first day of the month today

相关文章