You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
)
) to convert the date into utc
So in my case, with 'Europe/Paris' if $dateDue = '2024-11-12 00:00:00' Carbon converts this string as '2024-11-11 22:00:00' with the timezone UTC (+0) which is correct.
BUT when translatedFormat('d.m.Y') is used, 11.11.2024 is displayed instead of 12.11.2024.
So you need to tell Carbon to manage the date with the application's timezone
this is done with Carbon->setTimezone(date_default_timezone_get())
@forgive38, we should be consistent about where this is applied; I suspect everywhere else that Carbon::translatedFormat is called, this should also be added. Would you mind expanding the scope of this issue a little bit?
oh I was wrong
the problem isn't exactly that.
Carbon does parse a date taking into account the application's timezone, but not if it's a timestamp since Carbon version 3.
From Carbon doc: You can create instances from [unix timestamps](https://en.wikipedia.org/wiki/Unix_time). createFromTimestamp() create a Carbon instance equal to the given timestamp and will set the timezone to the given timezone as second parameter, or to UTC if non given (since Carbon 3) (in previous versions it defaulted to date_default_timezone_get())
and I looked at the code and didn't see the problem elsewhere
I'll rewrite the PR.
HTH
forgive38
added a commit
to forgive38/pkp-lib
that referenced
this issue
Nov 8, 2024
Describe the bug
I use "Europe/Paris" as timezone in config.inc.php
When a reviewer receive a review remind, the dates due are one day before (exemple : 15.10.2024 for 16.10.2024 in the Web UI)
I think it's happening here:
pkp-lib/classes/mail/variables/ReviewAssignmentEmailVariable.php
Line 83 in 43511e7
in fact, Carbon converts a date string (without tz) and uses the application's timezone (positioned here:
(
pkp-lib/classes/core/PKPApplication.php
Line 273 in 43511e7
) to convert the date into utc
So in my case, with 'Europe/Paris' if $dateDue = '2024-11-12 00:00:00' Carbon converts this string as '2024-11-11 22:00:00' with the timezone UTC (+0) which is correct.
BUT when translatedFormat('d.m.Y') is used, 11.11.2024 is displayed instead of 12.11.2024.
So you need to tell Carbon to manage the date with the application's timezone
this is done with
Carbon->setTimezone(date_default_timezone_get())
PR is coming
It's probably related to: #10264
(maybe use of UTC everywhere in the application is better, and use timezone only for user interactions)
What application are you using?
OJS 3.4 / main
The text was updated successfully, but these errors were encountered: