nexttime="1678628040000" 用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/h5V 著作权归作者所有。请勿转载和采集!