Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Date Time Laravel Package

brick/date-time

Immutable, ISO-8601–focused date/time API for PHP 8.2+ built on top of native DateTime, adding missing types like LocalDate, LocalTime, YearMonth, and MonthDay. Inspired by Java’s JSR-310, well-tested, production-ready, Composer installable.

View on GitHub
Deep Wiki
Context7
0.9.0

💥 Breaking changes

  • Minimum PHP version is now 8.2
  • The following classes are now final:
    • YearMonthRange
    • ZonedDateTime
    • Parser\DateTimeParseException
0.8.1

Compatibility improvements

  • The following parser and parse methods now accept hours only in timezone offsets, such as +01 equivalent to +01:00 (#123 by @antonkomarev):
    • IsoParsers:timeZoneOffset()
    • TimeZoneOffset::parse()
    • ZonedDateTime::parse()
0.8.0

💥 Breaking changes

  • Duration::toISOString() and __toString() now output negative durations as -P... (#122 by @BastienClement)
    Example: -PT2H21M instead of PT-2H-21M.
    This aligns with ISO 8601-2:2019 and improves compatibility with the JavaScript Temporal API.
0.7.1

🐛 Bug fixes

  • ZoneDateTime incorrectly handled DST Transitions with relative time addition (#115)

New features

  • LocalDate::getQuarter() and getQuarterValue() return the quarter of the year (#114 by @pscheit)
0.7.0

💥 Breaking changes

  • DayOfWeek:
    • deprecated method of() has been removed, use DayOfWeek::from() instead
    • the following deprecated methods have been removed, use enum values instead:
      • DayOfWeek::monday()DayOfWeek::MONDAY
      • DayOfWeek::tuesday()DayOfWeek::TUESDAY
      • DayOfWeek::wednesday()DayOfWeek::WEDNESDAY
      • DayOfWeek::thursday()DayOfWeek::THURSDAY
      • DayOfWeek::friday()DayOfWeek::FRIDAY
      • DayOfWeek::saturday()DayOfWeek::SATURDAY
      • DayOfWeek::sunday()DayOfWeek::SUNDAY
    • deprecated method getValue() has been removed, use $dayOfWeek->value instead
    • deprecated method is() has been removed, compare values with $dayOfWeek or $dayOfWeek->value instead
    • deprecated method isEqualTo() has been removed, use strict equality === between DayOfWeek instances instead.
  • DefaultClock:
    • deprecated method travel() has been removed, use travelTo() instead
  • LocalDate:
    • deprecated method getDay() has been removed, use getDayOfMonth() instead
    • getMonth() now returns a Month enum; use getMonthValue() if you want the month number
  • LocalDateTime:
    • deprecated method getDay() has been removed, use getDayOfMonth() instead
    • getMonth() now returns a Month enum; use getMonthValue() if you want the month number
  • Month:
    • deprecated method of() has been removed, use Month::from() instead
    • deprecated method getAll() has been removed, use Month::cases() instead
    • deprecated method getValue() has been removed, use $month->value instead
    • deprecated method is() has been removed, compare values with $month or $month->value instead
    • deprecated method isEqualTo() has been removed, use strict equality === between Month instances instead
  • MonthDay:
    • deprecated method getDay() has been removed, use getDayOfMonth() instead
    • getMonth() now returns a Month enum; use getMonthValue() if you want the month number
  • YearMonth:
    • getMonth() now returns a Month enum; use getMonthValue() if you want the month number
  • ZonedDateTime:
    • deprecated method getDay() has been removed, use getDayOfMonth() instead
    • getMonth() now returns a Month enum; use getMonthValue() if you want the month number

🔧 Improvements

  • Methods returning int are now type-annotated with int ranges
0.6.5

New methods

  • LocalDate::previousDayOfWeek()
  • LocalDate::previousOrSameDayOfWeek()
  • LocalDate::nextDayOfWeek()
  • LocalDate::nextOrSameDayOfWeek()
0.6.4

New features

  • DefaultClock::travelBy() travels in time by a duration (#92)

🗑️ Deprecations

  • DefaultClock::travel() is now deprecated in favour of travelTo() (#92)

Thanks to @francislavoie!

0.6.3

New features

  • Stopwatch::stop() now returns the lap duration (#98)

Thanks to @rodnaph!

0.6.2

New features

  • MonthDay::of() and MonthDay::withMonth() now accept a Month enum as parameter (#106)
  • LocalDate::of() and LocalDate::withMonth() now accept a Month enum as parameter (#106)
  • LocalDateTime::of() and LocalDateTime::withMonth() now accept a Month enum as parameter (#106)
  • ZonedDateTime::withMonth() now accepts a Month enum as parameter (#106)

Undeprecations

  • Passing an int to Year::atMonth() is un-deprecated, and now valid again (#103)
  • Passing an int to YearMonth::of() and YearMonth::withMonth() is un-deprecated, and now valid again (#103)
  • Passing an int to YearWeek::atDay() is un-deprecated, and now valid again (#103)

Thanks to @gnutix!

0.6.1

New features

  • Year::atMonth() now accepts a Month enum as parameter (#95)
  • YearMonth::of() and YearMonth::withMonth() now accept a Month enum as parameter (#96)

🔧 Improvements

  • Narrower Psalm types for compareTo(), __toString(), toISOString(), jsonSerialize() methods (#97)

💩 Deprecations

  • Passing an int to Year::atMonth() is now deprecated, pass a Month enum instead (#95)
  • Passing an int to YearMonth::of() and YearMonth::withMonth() is now deprecated, pass a Month enum instead (#96)

Thanks to @gnutix!

0.6.0

💥 Breaking changes

  • Minimum PHP version is now 8.1
  • DayOfWeek:
    • DayOfWeek is now an enum: constants MONDAY, TUESDAY, etc. are now DayOfWeek instances, not integers
    • the __toString() method is removed, use toString() instead (enums disallow magic methods)
    • the all() method does not accept null anymore, and defaults to DayOfWeek::MONDAY
  • Month:
    • Monthis now an enum: constants JANUARY, FEBRUARY, etc. are now Month instances, not integers
    • the __toString() method is removed, use toString() instead (enums disallow magic methods)

💩 Deprecations

  • DayOfWeek:
    • the of() method is deprecated, use DayOfWeek::from() instead
    • the following methods are deprecated, use enum values instead:
      • DayOfWeek::monday()DayOfWeek::MONDAY
      • DayOfWeek::tuesday()DayOfWeek::TUESDAY
      • DayOfWeek::wednesday()DayOfWeek::WEDNESDAY
      • DayOfWeek::thursday()DayOfWeek::THURSDAY
      • DayOfWeek::friday()DayOfWeek::FRIDAY
      • DayOfWeek::saturday()DayOfWeek::SATURDAY
      • DayOfWeek::sunday()DayOfWeek::SUNDAY
    • the getValue() method is deprecated, use $dayOfWeek->value instead
    • the is() method is deprecated, compare values with $dayOfWeek->value instead
    • the isEqualTo() method is deprecated, use strict equality === between DayOfWeek instances instead.
  • LocalDate:
    • getDay() is deprecated, use getDayOfMonth() instead
    • getMonth() is deprecated, use getMonthValue() instead (getMonth() will be repurposed to return a Month instance in a future release)
  • LocalDateTime:
    • getDay() is deprecated, use getDayOfMonth() instead
    • getMonth() is deprecated, use getMonthValue() instead (getMonth() will be repurposed to return a Month instance in a future release)
  • Month:
    • the of() method is deprecated, use Month::from() instead
    • the getAll() method is deprecated, use Month::cases() instead
    • the getValue() method is deprecated, use $month->value instead
    • the is() method is deprecated, compare values with $month->value instead
    • the isEqualTo() method is deprecated, use strict equality === between Month instances instead
  • MonthDay:
    • getDay() is deprecated, use getDayOfMonth() instead
    • getMonth() is deprecated, use getMonthValue() instead (getMonth() will be repurposed to return a Month instance in a future release)
  • YearMonth:
    • getMonth() is deprecated, use getMonthValue() instead (getMonth() will be repurposed to return a Month instance in a future release)
  • YearWeek:
    • the atDay() method now accepts a DayOfWeek instance, passing an integer is deprecated
  • ZonedDateTime:
    • getDay() is deprecated, use getDayOfMonth() instead
    • getMonth() is deprecated, use getMonthValue() instead (getMonth() will be repurposed to return a Month instance in a future release)
0.5.5

🐛 Bug fixes

  • Year::toISOString() / __toString() did not respect ISO 8601; years with less than 4 digits are now left-padded with zeros (#90)

Thanks to @andreaswolf!

0.5.4

🐛 Bug fixes

  • YearMonth::__toString() would return an invalid string for years < 1000 (#87)

New methods

  • Year::parse() and Year::from() (#86)
  • YearWeek::parse() and YearWeek::from() (#86)
  • the following classes now have a toISOString() method: (#87)
    • Duration
    • Instant
    • Interval
    • LocalDate
    • LocalDateRange
    • LocalDateTime
    • LocalTime
    • MonthDay
    • Period
    • Year
    • YearMonth
    • YearMonthRange
    • YearWeek
    • ZonedDateTime

The toISOString() methods return the same result as __toString(), but are better suited for the nullsafe operator:

$date?->toISOString();

⚡️ Performance optimizations

  • Most __toString() methods got a small performance boost (#85)

Thanks to @gnutix!

0.5.3

New methods

  • Instant::getIntervalTo() (#81)
  • ZonedDateTime::getIntervalTo() (#81)

Thanks to @solodkiy!

0.5.2

⚡️ Performance optimizations

  • These methods got a small performance boost: Local(Date|Time|DateTime) minOf()/maxOf() (#76)
  • Static objects returned by factory methods are now cached (#77)
  • The special case LocalDate::plusDays(1) is now much faster (#79)

Thanks to @gnutix and @BastienClement!

0.5.1

New methods

  • ZonedDateTime::getDurationTo() (#71) (@solodkiy)
0.5.0

💥 Breaking changes

  • Deprecated Interval constructor is now private; please use Interval::of() instead

  • The following deprecated methods have been removed, please use the new names:

    Class Name Old Method Name New Method Name
    LocalDate fromDateTime() fromNativeDateTime()
    LocalDate toDateTime() toNativeDateTime()
    LocalDate toDateTimeImmutable() toNativeDateTimeImmutable()
    LocalDateRange toDatePeriod() toNativeDatePeriod()
    LocalDateTime fromDateTime() fromNativeDateTime()
    LocalDateTime toDateTime() toNativeDateTime()
    LocalDateTime toDateTimeImmutable() toNativeDateTimeImmutable()
    LocalTime fromDateTime() fromNativeDateTime()
    LocalTime toDateTime() toNativeDateTime()
    LocalTime toDateTimeImmutable() toNativeDateTimeImmutable()
    Period fromDateInterval() fromNativeDateInterval()
    Period toDateInterval() toNativeDateInterval()
    TimeZone fromDateTimeZone() fromNativeDateTimeZone()
    TimeZone toDateTimeZone() toNativeDateTimeZone()
    ZonedDateTime fromDateTime() fromNativeDateTime()
    ZonedDateTime toDateTime() toNativeDateTime()
    ZonedDateTime toDateTimeImmutable() toNativeDateTimeImmutable()
0.4.3

🔧 Improvements

  • TimeZoneOffset::parse() return type has been narrowed to TimeZoneOffset
  • Support for seconds in TimeZoneOffset has been added back (#60) (@jiripudil)

🐛 Bug fixes

  • Old date/times could fail to be parsed by ZonedDateTime due to sub-minute timezone offsets (#44)
0.4.2

New methods

  • Duration::isGreaterThanOrEqualTo() (#50)
  • Duration::isLessThanOrEqualTo() (#50)
  • Interval::of() (#64)
  • Interval::contains() (#64)
  • Interval::intersectsWith() (#64)
  • Interval::getIntersectionWith() (#64)
  • Interval::isEqualTo() (#64)

💩 Deprecations

  • Interval constructor is deprecated in favour of Interval::of() (#64)

Thanks to @ihmels and @someniatko!

0.4.1

New methods

  • LocalDateRange::toPeriod() (#51)
  • Year::toLocalDateRange() (#46)
  • YearMonth::toLocalDateRange() (#46)
  • YearMonthRange::toLocalDateRange() (#46)
  • YearWeek::toLocalDateRange() (#46)

💩 Deprecations

The following methods have been deprecated in favour of new names (#47):

  • Period::fromDateInterval()fromNativeDateInterval()
  • Period::toDateInterval()toNativeDateInterval()
  • TimeZone::fromDateTimeZone()fromNativeDateTimeZone()
  • TimeZone::toDateTimeZone()toNativeDateTimeZone()
  • LocalTime::fromDateTime()fromNativeDateTime()
  • LocalTime::toDateTime()toNativeDateTime()
  • LocalTime::toDateTimeImmutable()toNativeDateTimeImmutable()
  • LocalDateRange::toDatePeriod()toNativeDatePeriod()
  • LocalDate::fromDateTime()fromNativeDateTime()
  • LocalDate::toDateTime()toNativeDateTime()
  • LocalDate::toDateTimeImmutable()toNativeDateTimeImmutable()
  • ZonedDateTime::fromDateTime()fromNativeDateTime()
  • ZonedDateTime::toDateTime()toNativeDateTime()
  • ZonedDateTime::toDateTimeImmutable()toNativeDateTimeImmutable()
  • LocalDateTime::fromDateTime()fromNativeDateTime()
  • LocalDateTime::toDateTime()toNativeDateTime()
  • LocalDateTime::toDateTimeImmutable()toNativeDateTimeImmutable()

Thanks to @solodkiy, and to @tigitz for introducing long overdue coding standards!

0.4.0

💥 Breaking changes

  • Minimum PHP version is now 7.4
  • TimeZoneOffset does not allow seconds anymore (#35):
    • TimeZoneOffset::of()'s $seconds parameter is removed
    • TimeZoneOffset::ofTotalSeconds() now throws if the number of seconds is not a multiple of 60
    • IsoParsers::timeZoneOffset() does not allow seconds in timezone offset anymore; this affects not only TimeZoneOffset:parse() but also ZonedDateTime::parse()

🔧 Fix

  • Fixed return type of TimeZoneRegion::parse() (#38) Thanks to @adrianguenter

New methods

  • Period::fromDateInterval() converts a native DateInterval object to Period
0.3.2

New methods

  • DayOfWeek::isWeekday()
  • DayOfWeek::isWeekend()
  • LocalDate::plusWeekdays()
  • LocalDate::minusWeekDays()
0.3.1

New methods

  • LocalDateRange::withStart()
  • LocalDateRange::withEnd()
0.3.0

💥 Breaking changes

  • The following methods now have return types:
    • Brick\DateTime\DayOfWeek::monday() through sunday()
    • Brick\DateTime\DayOfWeek::__toString()
    • Brick\DateTime\Month::__toString()
0.2.3

New method

🔧 Fix

  • Added missing ext-json requirement in composer.json
0.2.2

🐛 Bug fix

LocalDateTime::plusDuration() and LocalDateTime::minusDuration() could return the wrong day. (#25)

Thanks @JodyLognoul!

0.2.1

New methods

  • LocalDateRange::intersectsWith()
  • LocalDateRange::getIntersectionWith()

Thanks @solodkiy!

0.2.0

💥 Breaking changes

  • most of the project classes are now final (#8)
  • the following deprecated methods have been removed:
    • LocalDateRange::getStartDate() - use getStart() instead (#13)
    • LocalDateRange::getEndDate() - use getEnd() instead (#13)
    • Duration::ofMilliseconds() - use ofMillis() instead
0.1.16

New methods

  • LocalDateRange::getStart() - deprecates getStartDate()
  • LocalDateRange::getEnd() - deprecates getEndDate()

💩 Deprecations

  • LocalDateRange::getStartDate() is now deprecated and will be removed in 0.2.0.
  • LocalDateRange::getEndDate() is now deprecated and will be removed in 0.2.0.

This makes LocalDateRange consistent with YearMonthRange.

0.1.15

🛠 Improvement

The following classes now implement JsonSerializable (#19):

  • DayOfWeek
  • Duration
  • Instant
  • Interval
  • LocalDate
  • LocalDateRange
  • LocalDateTime
  • LocalTime
  • Month
  • MonthDay
  • Period
  • Year
  • YearMonth
  • YearMonthRange
  • YearWeek
  • ZonedDateTime

Thanks to @kagmole!

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky