Getting current unixtimestamp using Moment.js
To find the Unix Timestamp in seconds:
moment().unix()
The documentation is your friend. :)
for UNIX time-stamp in milliseconds
moment().format('x') // lowerCase x
for UNIX time-stamp in seconds
moment().format('X') // capital X
For anyone who finds this page looking for unix timestamp w/ milliseconds, the documentation says
moment().valueOf()
or
+moment();
you can also get it through moment().format('x')
(or .format('X')
[capital X] for unix seconds with decimal milliseconds), but that will give you a string. Which moment.js won't actually parse back afterwards, unless you convert/cast it back to a number first.
NOTE: This answer continues to get +1s, which is nice, but Moment has been depreciated, and alternatives like Luxon
or date-fns
are suggested. See: https://momentjs.com/docs/#/-project-status