-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deprecate DateTimeImmutable #1928
Conversation
Thanks |
FYI, citing https://semver.org/
|
Not sure what you're trying to say? |
New version should have been 3.9.0, not 3.8.1 |
Ah I see. Yeah that was a mistake rushing this release while sitting at SymfonyCon. |
$this->useMicroseconds = $useMicroseconds; | ||
|
||
// if you like to use a custom time to pass to Logger::addRecord directly, | ||
// call modify() or setTimestamp() on this instance to change the date after creating it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't immutable mean that you can't modify the instance?
I tested locally, and setTimestamp
does nothing, I was expecting it to throw.
$ php -r '$t = new \DateTimeImmutable(); $t->setTimestamp(123); echo PHP_VERSION, "\n", $t->getTimestamp(), "\n";'
8.4.2
1735898810
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class behaves the same as DateTime except new objects are returned when modification methods such as DateTime::modify() are called.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to use the instance returned by setTimestamp and pass that to Logger::addRecord as custom datetime instance.
Fixes #1926