Skip to content

Instantly share code, notes, and snippets.

@toshvelaga
Last active February 13, 2022 06:36
Show Gist options
  • Select an option

  • Save toshvelaga/f72aab35158dc1a9264d66f3aa02c7d2 to your computer and use it in GitHub Desktop.

Select an option

Save toshvelaga/f72aab35158dc1a9264d66f3aa02c7d2 to your computer and use it in GitHub Desktop.
The time in days from when the user registered to today
const timeFromUserRegistration = (dateUserRegistered) => {
// example of dateUserRegistered = '2021-07-30T05:05:27.000Z'
const userDataRegistered = Date.parse(dateUserRegistered)
const currDate = Date.parse(new Date())
const dateDiff = currDate - userDataRegistered
console.log(dateDiff)
const days = dateDiff / (60 * 60 * 24 * 1000)
return days
}
export default timeFromUserRegistration;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment