-1

I have a property created_at which stores Date and time of users that sign in for. So using Moment.js I want to get the number of days from "latest date" -"created_at".

moment(new Date()).diff(tag.created_at)
Sergo Pasoevi
  • 2,833
  • 3
  • 27
  • 41
Sohan
  • 558
  • 6
  • 17
  • 1
    Have you tried `moment().diff(moment(tag.created_at), 'days')`? – Tholle Apr 15 '19 at 11:09
  • Possible duplicate of [How to calculate number of days between two dates](https://stackoverflow.com/questions/9129928/how-to-calculate-number-of-days-between-two-dates) – Shantiswarup Tunga Apr 15 '19 at 12:32

1 Answers1

1

You should be able to get the number of days between to dates a and b as follows (using Moment):

a.diff(b, 'days')
Phillip
  • 6,033
  • 3
  • 24
  • 34
  • Yes, It worked. But I did ”{moment.duration(moment(tag.created_at).diff(moment(new Date()))).humanize()+’ ago’}”. And it worked Fine. Thanks BTW – Sohan Apr 15 '19 at 12:01