Moment.js has been retired. It had math operations on dates. I think Math is helpful on Dates.
With
moment
importmomentfrom'moment'constnow=Date.now()consttoday=moment.utc(now)constmomentYesterday=today.subtract(1,'days')With
@taystack/getDate:
import{getDate,subtractDays}from'@taystack/get-date'// es6// const { getDate, subtractDays } = require('@taystack/get-date') // es5constnow=Date.now()consttoday=getDate(now)constgetDateYesterday=subtractDays(now,1)There are no dependencies. This is a small set of helpers for working with native Javascript Date objects.
npm i @taystack/get-dateimport{getDate}from'@taystack/get-date'getDate()// Same as new Date()getDate(0)// new Date(0) -> jan 1 1970import{getTime}from'@taystack/get-date'getTime()// Same as Date.now()getTime(0)// 0 -> Short-hand new Date(0).getTime()