Skip to content

Use Carbon::now() for fresh timestamps so that Carbon's time mocking works #1870

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

Merged
merged 4 commits into from
Jan 17, 2020

Conversation

manan-jadhav
Copy link
Contributor

No description provided.

@passionInfinite
Copy link

@CurosMJ This will break the default behaviour of Carbon::now . As it will return you the string not the instance which breaks the further usage of toDateTimeString().

@@ -118,7 +118,7 @@ public function getDateFormat()
*/
public function freshTimestamp()
{
return new UTCDateTime(time() * 1000);
return new UTCDateTime(Carbon::now());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be:

Suggested change
return new UTCDateTime(Carbon::now());
return new UTCDateTime(Carbon::now()->getTimestamp() * 1000);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like UTCDateTime also supports DateTime interfaces 👌

@jenssegers jenssegers merged commit 811cb3d into mongodb:master Jan 17, 2020
mnphpexpert added a commit to mnphpexpert/laravel-mongodb that referenced this pull request Sep 2, 2024
Use Carbon::now() for fresh timestamps so that Carbon's time mocking works
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants