我正在尝试一次使用 PHP 和 MySQL(仅在工作日)插入频繁的工作时间。
从 : 01.02.2013 08:30
到 : 28.02.2013 17:30
然后它应该插入每个工作日直到 28.02.2013 这样
01.02.2013 08:30 -01.02.2013 17:30
02.02.2013 08:30 -02.02.2013 17:30
03.02.2013 08:30 -03.02.2013 17:30
...
您能否提供一些从哪里开始的提示?
我用下面的代码只插入一个日期..
$startDate = $rsnew["starttime"];
$endDate = $rsnew["endtime"];
// Convert to UNIX timestamps
$currentTime = strtotime($startDate);
$endTime = strtotime($endDate);
// Loop until we reach the last day
$result = array();
while ($currentTime <= $endTime) {
if (date('N', $currentTime) < 6) {
$result[] = date('Y-m-d', $currentTime);
}
$currentTime = strtotime('+1 day', $currentTime);
echo "Hallo" .$currentTime;
}
// start insertion
foreach($result as $value)
{
$MyResult = ew_Execute("INSERT INTO dates (date) VALUES ('".$value."')");
echo "Hallo" .$value;
}