Getting the formatted values back from timestamps

Now that we have this in place, we have everything we need to actually take those timestamps and get back formatted values. The other thing we can do is we can create timestamps with Moment, it has the exact same effect as the new Date().getTime method we've used.

In order to do this, all we do is we call moment.valueOf. For example, we can make a variable called someTimestamp, setting it equal to a call to moment. We're going to generate a new moment and we're going to call its valueOf method.

This is going to go ahead and return a timestamp in milliseconds since the Unix epoch, console.log. We're going to log out the someTimestamp variable just to make sure it looks correct, and here we ...

Get Advanced Node.js Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.