Skip to content

Instantly share code, notes, and snippets.

@b0n
Created August 2, 2016 04:15
Show Gist options
  • Save b0n/95f2332b8a0acb118434bf6213a0b90b to your computer and use it in GitHub Desktop.
Save b0n/95f2332b8a0acb118434bf6213a0b90b to your computer and use it in GitHub Desktop.
Chronos failures add months tesst.
<?php
/**
* @url http://scriptworks.jp/blog/2011/12/how_to_avoid_pitfall_of_php_datetime/
*/
require 'vendor/autoload.php';
use Cake\Chronos\Date;
$today = new Date('2011-01-31');
echo $today . PHP_EOL;
echo $today->modify('+1 months') . PHP_EOL;
// 2011-01-31
// 2011-03-03
$today2 = new Date('2011-03-31');
echo $today2 . PHP_EOL;
echo $today2->modify('-1 months') . PHP_EOL;
// 2011-03-31
// 2011-03-03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment