|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73301 DateTime::setTime breaks backwards compatibility
Submitted: 2016-10-12 11:53 UTC Modified: 2016-10-12 13:25 UTC
From: sjon at hortensius dot net Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 7.1Git-2016-10-12 (Git) OS:
Private report: No CVE-ID: None
 [2016-10-12 11:53 UTC] sjon at hortensius dot net
DateTime::setTime was changed between RC3 and RC4 in a backward breaking way which seems highly unwanted.

Warning: Declaration of Custom_DateTime::setTime($hour, $minute, $second = 0) should be compatible with DateTime::setTime($hour, $minute, $second = NULL, $microseconds = NULL)

This causes applications to break; why was $second=0 not kept as a default?


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-10-12 12:22 UTC]
This is not related to the default value (which has not changed). We generally do not allow removing parameters, even optional ones, from method signatures:
 [2016-10-12 12:37 UTC] sjon at hortensius dot net
Ah, right; I was thrown off by the Exception message. It's nice functionality; and I'm not saying DateTime::setMicroTime would be better; but I'm also not sure about the timing of this feature.

Apparently quite a few issues were fixed by introducing this @
 [2016-10-12 13:25 UTC]
-Status: Open +Status: Not a bug
 [2016-10-12 13:25 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

This works as it supposed to be. There were no changes to the original defaults.
This addition was part of supporting, and fixing, microtime support across the board.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Jun 17 04:01:31 2024 UTC