-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Carbon 3 createFromTimestamp undocumented timezone change #2948
Comments
Hello, they are not identical because Carbon::createFromTimestamp(time(), date_default_timezone_get()); The change is that we no longer assume that While you're switching from Carbon 2 to 3, I suggest you carefully consider them as it's possibly a good occasion to also change some settings that might help on the long run:
It's a though topic I tried to explain more in details here: |
Appreciate the explanation, I still think this requires a substantial highlight in the upgrade docs |
Documentation updated. |
It will break the createFromTimestamp's behavior. I think it will be better to change the sign of createFromTimestamp, like mark the second parameter as required. |
Carbon 3 is already live for ~1 year. Making the timezone required in 4.x is a possibility but I'm not sure it's worth yet another breaking change. |
In the current PHP ecosystem, nesbot/carbon is de facto the best date management library. Therefore, a large number of community libraries rely on it and trust its API design. I've seen in quite a few popular community libraries that their dependency settings for nesbot/carbon are: I can find a large number of libraries and code with such compatibility issues by searching on GitHub at https://github.com/search?q=%22Carbon%3A%3AcreateFromTimestamp%22+language%3APHP&type=code&p=1. For example: So, it's really a troublesome thing indeed... |
In Carbon 3,
createFromTimestamp()
no-longer applies the default timezone.createFromTimestamp(time())
returns without timezone, while in Carbon 2 the default timezone is applied. If this is an intended change then it's not very well documented.Basically
createFromTimestampUTC
in Carbon 2 is nowcreateFromTimestamp
in Carbon 3.The text was updated successfully, but these errors were encountered: