Merge pull request #482 from hannesvdvreken/gh-pages

Teach to use Y-m-d
This commit is contained in:
Phil Sturgeon
2014-12-04 09:46:49 -05:00

View File

@@ -17,7 +17,7 @@ output.
$raw = '22. 11. 1968';
$start = \DateTime::createFromFormat('d. m. Y', $raw);
echo 'Start date: ' . $start->format('m/d/Y') . "\n";
echo 'Start date: ' . $start->format('Y-m-d') . "\n";
{% endhighlight %}
Calculating with DateTime is possible with the DateInterval class. DateTime has methods like `add()` and `sub()` that
@@ -52,7 +52,7 @@ $periodInterval = \DateInterval::createFromDateString('first thursday');
$periodIterator = new \DatePeriod($start, $periodInterval, $end, \DatePeriod::EXCLUDE_START_DATE);
foreach ($periodIterator as $date) {
// output each date in the period
echo $date->format('m/d/Y') . ' ';
echo $date->format('Y-m-d') . ' ';
}
{% endhighlight %}