php – die nächsten Mittwoche berechnen

“Mittwoche” klingt irgendwie falsch … ;)

for ($i = 0; $i < = 4; $i++) {
	if ($i == 0) {
		$next_wednesday[$i] = date("Y-m-d", strtotime("next Wednesday"));
	}
	else {
		$next_wednesday[$i] = date("Y-m-d", strtotime("next Wednesday", strtotime($next_wednesday[($i-1)])));
	}
}

// DEBUG
print_r($next_wednesday);

crontab: Tipp

Einfach folgenden Kommentar in der crontab eintragen … ;)

 

#* * * * * command to be executed
#- – – – –
#| | | | |
#| | | | +—– day of week (0 – 6) (Sunday=0)
#| | | +——- month (1 – 12)
#| | +——— day of month (1 – 31)
#| +———– hour (0 – 23)
#+————- min (0 – 59)