-
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
fix: Time::createFromTimestamp()
sets incorrect time when specifying timezone
#5588
Conversation
a2bd954
to
7602cb4
Compare
@totoprayogo1916 I'm not sure what the intent of this PR is. |
case: $time = new Time('now');
$timestamp = $time->timestamp;
$new_time = Time::createFromTimestamp($timestamp);
$new_time_timezone = Time::createFromTimestamp($timestamp, config('App')->appTimezone);
var_dump(
$time->toDateTimeString(),
$new_time->toDateTimeString(),
$new_time_timezone->toDateTimeString()
); The date doesn't change even though the timezone has been added. |
@totoprayogo1916 This is complicated timezone issue.
What's wrong with it? |
Test added |
7db80d6
to
6682e25
Compare
The time is changed when specify timezone. $time = new Time('2022/01/18 00:00:00');
$new_time = Time::createFromTimestamp($time->timestamp);
$new_time_timezone = Time::createFromTimestamp($time->timestamp, 'Asia/Jakarta');
var_dump(
$time->getTimestamp(),
$new_time->getTimestamp(),
$new_time_timezone->getTimestamp()
);
|
timestamp changed, but Date not. |
Time::createFromTimestamp()
Time::createFromTimestamp()
sets incorrect time when specifying timezone
I got what you mean when I saw your var_dump output. |
The timestamp is always based on UTC, so the current behavior is a bug, right? |
beaf153
to
0864b4d
Compare
previously not updating date even though time zone has been set
0864b4d
to
1e5cc13
Compare
apply suggestion Co-authored-by: kenjis <kenji.uui@gmail.com>
1e5cc13
to
a7dfa5f
Compare
Description
previously not updating date even though time zone has been set
Checklist: