Skip to content
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

Laravel 11 can't get the UTC timestamp #50490

Closed
jevantang opened this issue Mar 12, 2024 · 9 comments
Closed

Laravel 11 can't get the UTC timestamp #50490

jevantang opened this issue Mar 12, 2024 · 9 comments

Comments

@jevantang
Copy link

Laravel Version

11.0.0

PHP Version

8.2.16

Database Driver & Version

MySQL 5.7.44 for Ubuntu 22

Description

I've tried three methods and I can't get the UTC+0 timestamp.

The time value is correct until it is converted to a timestamp.

Laravel 10 was valid code, upgrading to 11 caused problems. No server environment has been changed.

Steps To Reproduce

$now = now('UTC');
$nowTimestamp = $now->getTimestamp();
$nowTimestamp = time();
$now = now('UTC');
$nowTimestamp = strtotime($now);
@driesvints
Copy link
Member

@jevantang what Carbon version are you using?

@jevantang
Copy link
Author

@jevantang what Carbon version are you using?

name : nesbot/carbon
versions : * 3.0.2
released : 2024-02-06, 1 month ago

@Muetze42
Copy link
Contributor

Muetze42 commented Mar 12, 2024

I use always now()->timestamp for this.

@akr4m
Copy link
Contributor

akr4m commented Mar 12, 2024

image image

@Muetze42

@driesvints
Copy link
Member

You'll have to report this to the carbon repo as we don't control that code sorry.

@Muetze42
Copy link
Contributor

The timestamp is correct, isn't it?

image

@jevantang
Copy link
Author

The timestamp is correct, isn't it?

image

@Muetze42

1710276559 -> 2024-03-13 04:49:19
Current UTC+0 Time 2024-03-12 20:49:19

@jyxjjj
Copy link

jyxjjj commented Mar 13, 2024

1710276559 ->2024-03-13 04:49:19

@jevantang How do you convert it?
1710276559 is equals to 20:49:19.
Timestamp has no timezone it always UTC+0000. where is the 8?

@kylekatarnls
Copy link
Contributor

You'll have to report this to the carbon repo as we don't control that code sorry.

For the record, this issue is not related to Carbon since time() is giving the same value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants