Moment .from() is calculating the wrong time difference

This seems odd to me. Using Moment, it seems to think today's date is far into the future.

I'm just trying to get the relative difference between a timestamp and now, but 8 months ago is quite wrong... any thoughs?

image

Cheers!

Hello @aidenmitchell!

Very interesting find :thinking: not sure why moment's from() function would do be returning 8 months...

In your given example, should it be returning zero days and zero months with the query.data.created_at being the the date that a new moment object would create?

My first guess would be that the formatting is different, and that is causing the subtraction behind the scenes during the .from() method to improperly, since in the second part of line 1 you are passing query3.data.created_at into moment(), which should format it correctly.

Could you save that without the .from() at the end to a var and see what it is returning?

I just did some reverse engineering testing and Moment seems to work on my end.

I set a var to be one day in the past, then in a text box editor, display the var's date and created a current date with moment() and passed in the 'one-day-ago' date as the arg to from() and it returned the difference "in a day".

Could you test out moment().from(query3.data.created_at) to see if it gives the proper "reverse" date difference, as well as with the variable that is storing moment(query3.data.created_at) to see if what they return for you and if there is a formatting discrepancy?

I would expect/hope passing in the query's created at date would work to make a proper moment object that could then be used with .from() grabbing our current date but it isn't which is super odd :face_with_monocle: