PHP代码:获取指定时间戳的星期几
可以使用PHP中的date()函数和strtotime()函数来实现。
代码如下:
$nexttime = '1678628040000';
$weekday = date('l', strtotime(date('Y-m-d', $nexttime/1000)));
echo '下一个时间是' . $weekday;
输出结果为:
下一个时间是Friday
解释一下代码:
- 将传入的时间戳除以1000,将其转为秒数。
- 使用
strtotime()函数将其转为日期格式,再使用date()函数获取该日期对应的星期几(用'l'参数表示)。 - 最后输出结果。
原文地址: https://www.cveoy.top/t/topic/lBXx 著作权归作者所有。请勿转载和采集!