<?php
function date_generator($ex_weeks = array(), $ex_DateTimeObjects = array()) {
$kanji_w = array('日', '月', '火', '水', '木', '金', '土');
$current = new DateTime('now', new DateTimezone('Asia/Tokyo'));
for ($i = 0; $i < 30; $i++) {
$current->add(new DateInterval('P1D'));
if ($i < 2 || in_array($current->format('w'), $ex_weeks)) {
continue;
}
foreach ($ex_DateTimeObjects as $object) {
if (!$object->diff($current)->days) {
continue 2;
}
}
$w = $kanji_w[$current->format(' (w)')];
yield $current->format('n月j日') . $w;
}
}
?>
<select name="date">
<?php foreach (date_generator(array(1), array(new DateTime('12/25'))) as $value): ?>
<option value="<?=$value?>"><?=$value?></option>
<?php endforeach; ?>
</select>
preferences:
32.34 ms | 402 KiB | 5 Q