https://github.com/activecollab/datevalue
Simple extension to Carbon that makes distinction between date and date-time objects
https://github.com/activecollab/datevalue
Last synced: 12 months ago
JSON representation
Simple extension to Carbon that makes distinction between date and date-time objects
- Host: GitHub
- URL: https://github.com/activecollab/datevalue
- Owner: activecollab
- License: mit
- Created: 2015-10-10T12:24:45.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2022-08-10T07:30:29.000Z (almost 4 years ago)
- Last Synced: 2025-06-12T02:19:45.245Z (about 1 year ago)
- Language: PHP
- Homepage: httsp://labs.activecollab.com
- Size: 81.1 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DateValue
[](https://travis-ci.org/activecollab/datevalue)
Simple extension to Carbon that makes distinction between date and date-time objects. In order to create a date object, write:
```php
format('Y-m-d') . "\n";
```
In order to create a date and time object, create a `DateTimeValue` instance:
```php
format('Y-m-d H:i:s') . "\n";
```
Since both DateValue, and DateTimeValue classes extend Carbon, you can also use all Carbon methods in your code:
```php
endOfDay();
print $date_time->format('Y-m-d H:i:s') . "\n";
```
To specify a date range, use DateRange class. Ranges can be easily iterated:
```php
assertInstanceOf(DateValueInterface::class, $day);
print $day->format('Y-m-d') . "\n"; // Prints all days from 2017-04-01 to 2017-04-30.
}
```
There are three helper date range classes:
```php