Set the ISO date in PHP
Description
The following code shows how to set the ISO date.
Example
//from w w w . j a va 2 s. com
<?php
$date = new DateTime();
$date->setISODate(2008, 2);
echo $date->format('Y-m-d') . "\n";
$date->setISODate(2008, 2, 7);
echo $date->format('Y-m-d') . "\n";
//Values exceeding ranges are added to their parent values
$date->setISODate(2008, 2, 7);
echo $date->format('Y-m-d') . "\n";
$date->setISODate(2008, 2, 8);
echo $date->format('Y-m-d') . "\n";
$date->setISODate(2008, 53, 7);
echo $date->format('Y-m-d') . "\n";
$date->setISODate(2008, 14);
echo $date->format('n');
?>
The code above generates the following result.