Comments (3)
Hello,
Which timezone are you on? Because we are the 29th now in most places in the world. So maybe you just need to specify the timezone you want:
Carbon::parse('2024-02-29', '-13:00')->isFuture()
is true
now, but anything less than -12:00
would be accurately false
now.
For the record, it's binary past or future, there is no present and 2024-02-29
stands for 2024-02-29 00:00:00.000000
, Carbon objects (like DateTime
) are not representing a period but always an exact moment as you can see if you do:
Carbon::parse('2024-02-29')->format('Y-m-d H:i:s.u e')
You would see what the exact date-time and timezone that the object represents.
from carbon.
Documentation of the method explicitly state reference point is now
, not Today
, and examples using hours demonstrates the granularity of it:
Determines if the instance is in the future, ie. greater (after) than now.
Example:
Carbon::now()->addHours(5)->isFuture(); // true Carbon::now()->subHours(5)->isFuture(); // false
Side note, you can easily exclude Today as a special case:
$february29Midnight = Carbon::parse('2024-02-29');
if ($february29Midnight->isToday()) {
echo 'Happily working 1 more day this year :D';
} elseif ($february29Midnight->isFuture()) {
echo "It's still after Today";
} else {
echo "It's before Today";
}
from carbon.
Never mind. I thought today was 28.02. I'm sorry.
from carbon.
Related Issues (20)
- Singular methods without parameters also work with parameters. It should not be as per the documentation. HOT 1
- Inconsistent Date Calculation When Adding Months Across February HOT 5
- Carbon\Carbon::rawAddUnit(): Argument #3 ($value) must be of type int|float, string given HOT 5
- Failed to parse time dd/mm/yyyy using parseFromLocale with Portuguese HOT 1
- Check month issue HOT 1
- PHP Version < 7.4 broken HOT 2
- Psalm reports MissingDependency on CarbonPeriod HOT 1
- Syntax Supported Only After PHP 7.4 Causes Errors in Versions Prior to 7.4 HOT 1
- Undocumented breaking change: isSameMonth() HOT 3
- CarbonPeriod loses timezone when accessing days
- Using "Depends on the following methods" @method in traits causes PHPStan to lose knowledge of type resulting in errors
- 2.7.4 is not support php7.3 HOT 1
- PHPSandbox is not working properly HOT 2
- `age` function does not calculate the age correctly for Carbon >= 3 HOT 1
- DateInterval CarbonInterval Carbon - Laravel 11 HOT 3
- Remove copy() & Make all arithmetic immutable. HOT 1
- Cant create negative interval between 00:00 and -01:00 HOT 2
- Czech (CS) uses genitive case when using iso format `MMMM YYYY`
- Misleading error message in `createFromFormat` HOT 8
- Type Error with setUnit() function in Date.php file HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from carbon.