Example #1
0
    else
    while($date->format('m')-$init->format('m')!=$months%12)
    $date->modify('-1 day');
    */
    //echo 'sdfsdsd';
}
function addYears($date, $years)
{
    $init = clone $date;
    $modifier = $years . ' years';
    $date->modify($modifier);
    while ($date->format('m') != $init->format('m')) {
        $date->modify('-1 day');
    }
}
addMonths($date, 1);
//addYears($date,3);
//echo $date->format('m j,Y');
//exit;
//echo time();exit;
print_r(Khayyam\Khayyam::now()->toDateTimeString());
echo "\n";
print_r(Khayyam\Khayyam::createFromDate(1393, 5, 21)->age);
exit;
print_r(date_parse("@1711005151058451"));
exit;
//array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
date_default_timezone_set('Asia/Tehran');
/*
$d = new \Khayyam\DateTime;
echo ($d->format('l Y-m-d H:i:s')) . PHP_EOL;
Example #2
0
/* DOCS
http://php.net/manual/en/function.strtotime.php 
http://php.net/manual/en/function.date.php 
*/
echo '<br />';
/* now with functions... */
function addDays($date, $format, $days)
{
    return date($format, strtotime($date . "+" . $days . " days"));
}
function addMonths($date, $format, $months)
{
    return date($format, strtotime($date . "+" . $months . " months"));
}
function formatDate($date, $format)
{
    return date($format, strtotime($date));
}
$format = 'Y-m-d';
$date = "2016-02-22";
$date = addDays($date, $format, 4);
$date = addMonths($date, $format, 3);
echo formatDate($date, 'd/m/Y');
/* = thousands of tedious heavy-parametrized functions catalog, one for every problem to solve...*/
/* good luck finding the one you need */
/*now with objects...*/
$date = new MyDate("2016-02-22", 'Y-m-d');
$date->addDays(4);
$date->addMonths(3);
echo $date->format('d/m/Y');
/* perfectly understandable code, well organized (every object has its own set of functions)  */