Frage

Ich brauche zwei Daten in "Ymd" Format zu erklären: $toDate und $fromDate

.

$toDate stellt das heutige Datum und $fromDate Bedürfnisse 4 Monate früher sein als heute.

$toDate = Date('Ymd');
$fromDate = ?

Wie erstelle ich $fromDate?

War es hilfreich?

Lösung

Use the magic of strtotime:

$fromDate = date("Ymd", strtotime("-4 months"));

Andere Tipps

see the code below...

$fourmonthsback = date("Ymd", mktime(0, 0, 0, date("m")-4, date("d"),   date("Y")));

OR

$fourmonthsback = mktime(0, 0, 0, date("m")-4, date("d"),   date("Y"));
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top