mirror of
https://github.com/Seldaek/monolog.git
synced 2026-04-26 08:05:53 +03:00
[GH-ISSUE #1881] DatetimeImmutable #802
Labels
No labels
Bug
Documentation
Feature
Needs Work
Support
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/monolog#802
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Misosooup on GitHub (Apr 10, 2024).
Original GitHub issue: https://github.com/Seldaek/monolog/issues/1881
Monolog version 1|2|3?
Write your question here.
Hi,
In the Logger.php, there is a function called
addRecordwhich takes in DateTimeImmutable. This object is an object of the Monolog package.In that function, you have stated that this argument is log date to log in the past or the future. However, when creating the Monolog DateTimeImmutable object, there is no way to set the date for this object. It always default to
now. There is no way for me to pass through the base DateTimeImmutable object to the addRecord function as it is strict typed to Monolog\DateTimeImmutable.I feel like there is some inconsistency here as the function allows a future or a past date, yet the DateTimeImmutable object itself doesn't. Are we meant to use it like this?
@Seldaek commented on GitHub (Apr 12, 2024):
The way to do it is
(new DateTimeImmutable(true))->modify('2022-03-04 05:06:07')if you want to set the date to something specific.