Discussion:
[mongodb-user] How to convert mongodb timestamp to date format
Madabhattula Rajesh Kumar
2018-06-12 17:45:24 UTC
Permalink
Hi,

I have a following timestamp which is returned from mongo database. How to
convert this into Date fomat(%Y-%m-%d %H:%M:%S)

*timestamps*

43263.50444579861
43263.50789454861
43263.51139024306
43263.5148625
43263.51833471065
43263.52180701389
43263.525255659726
43263.528727881945
43263.53222354167
43263.535695810184

Regards,
Rajesh
--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.

For other MongoDB technical support options, see: https://docs.mongodb.com/manual/support/
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user+***@googlegroups.com.
To post to this group, send email to mongodb-***@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/44acd43c-3180-4ec6-937c-aa8fec7e1c6e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
'Kevin Adistambha' via mongodb-user
2018-06-25 07:38:46 UTC
Permalink
Hi

How did you generate the timestamps? It doesn’t look like a UNIX epoch
<https://en.wikipedia.org/wiki/Unix_time> or any standard time format.

MongoDB includes the Date type
<https://docs.mongodb.com/manual/core/shell-types/#date>. Once you convert
those timestamps to a Date type, you can use the aggregation framework’s
$dateToString
<https://docs.mongodb.com/manual/reference/operator/aggregation/dateToString/>
to convert the dates to your required format.

Best regards
Kevin
​
--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.

For other MongoDB technical support options, see: https://docs.mongodb.com/manual/support/
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user+***@googlegroups.com.
To post to this group, send email to mongodb-***@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/4ceb3dda-8dbd-4ce2-aa5a-ed25cc930a6f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...