2025年01月20日 建站教程
如何利用php语法将月份区间转为时间戳(比如5-10月份转换成时间戳),下面web建站小编给大家简单介绍一下具体实现代码!
将从5月到10月的月份都转换为时间戳:
$start_month = 5;
$end_month = 10;
$year = 2023;
for ($month=$start_month; $month<=$end_month; $month++) {
$days_in_month = cal_days_in_month(CAL_GREGORIAN, $month, $year);
$total_days = $days_in_month * ($month - $start_month);
$timestamp = strtotime("{$year}-{$month}-1 00:00:00") + $total_days * 86400;
echo $timestamp . '<br>';
}
本文链接:http://so.lmcjl.com/news/21685/