Skip to content

Instantly share code, notes, and snippets.

@cp-sumi-k
Last active November 8, 2022 09:51
Show Gist options
  • Save cp-sumi-k/ec4f585cecaca78594c8e3810f6f89c7 to your computer and use it in GitHub Desktop.
Save cp-sumi-k/ec4f585cecaca78594c8e3810f6f89c7 to your computer and use it in GitHub Desktop.
// Current date in millis : 1667813042954
// A year ago : 1636280463554
console.log("A year ago : ", new Date().setYear(cDate.getFullYear() - 1))
// 3 months ago : 1659867711241
console.log("3 months ago : ", new Date().setMonth(cDate.getMonth() - 3))
// 2 days ago : 1667643213795
console.log("2 days ago : ", new Date().setDate(cDate.getDate() - 2))
// 2 hours ago : 1667809705405
console.log("2 hours ago : ", new Date().setHours(cDate.getHours() - 2))
// 5 minutes ago : 1667816708972
console.log("5 minutes ago : ", new Date().setMinutes(cDate.getMinutes() - 5))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment