Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

This post shows up still in 2019 🔢 #2483

Unanswered
bswatantra asked this question in Q&A
Discussion options

This post shows up still in 2019 🔢

use MongoDB\BSON\UTCDateTime;

new UTCDateTime(new \DateTime('now'));

Carbon extends DateTime so a carbon instance should be usable:

new UTCDateTime(Carbon::now());

Originally posted by @marcnewton in #594 (comment)

You must be logged in to vote

Replies: 1 comment 1 reply

Comment options

while fetching data I get

"created_at": {
 "$date": {
 "$numberLong": "1653035305018"
 }
 }

but I want it

2022年05月20日T08:28:25.021000Z
OR
022-05-20 14:13:27
You must be logged in to vote
1 reply
Comment options

Hi @bswatantra,
I think this issue is not related to this repo. I suggest you to always save dates to database like this:
new UTCDateTime(new DateTime($mydate));
I think it is the only way to retrieve a correct instance of date.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
Converted from issue

This discussion was converted from issue #2388 on December 17, 2022 18:07.

AltStyle によって変換されたページ (->オリジナル) /