Created
August 2, 2016 05:08
-
-
Save b0n/9f1d00c05a62d92a6cb66b2133186ba0 to your computer and use it in GitHub Desktop.
nesbot/carbon return value
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require 'vendor/autoload.php'; | |
use Carbon\Carbon; | |
echo '-- add sub 1 months --', PHP_EOL; | |
$dt1 = Carbon::createFromDate(2011, 1, 31); | |
echo $dt1->toDateString(), PHP_EOL; | |
echo $dt1->addMonth()->toDateString(), PHP_EOL; | |
$dt2 = Carbon::createFromDate(2011, 3, 31); | |
echo $dt2->toDateString(), PHP_EOL; | |
echo $dt2->subMonth()->toDateString(), PHP_EOL; | |
echo '-- add sub 1 month with a first day of month --', PHP_EOL; | |
$dt3 = Carbon::createFromDate(2011, 1, 31); | |
echo $dt3->toDateString(), PHP_EOL; | |
echo $dt3->startOfMonth()->addMonth()->endOfMonth()->toDateString(), PHP_EOL; | |
$dt4 = Carbon::createFromDate(2011, 3, 31); | |
echo $dt4->toDateString(), PHP_EOL; | |
echo $dt4->startOfMonth()->subMonth()->endOfMonth()->toDateString(), PHP_EOL; | |
echo '-- leap year --', PHP_EOL; | |
$dt5 = Carbon::createFromDate(2016, 1, 31); | |
echo $dt5->toDateString(), PHP_EOL; | |
echo $dt5->startOfMonth()->addMonth()->endOfMonth()->toDateString(), PHP_EOL; | |
$dt6 = Carbon::createFromDate(2016, 3, 31); | |
echo $dt6->toDateString(), PHP_EOL; | |
echo $dt6->startOfMonth()->subMonth()->endOfMonth()->toDateString(), PHP_EOL; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment