Formatting and Updating Message Timestamps

Your messages have timestamps that are not very human-friendly. (Seriously, who tells time by the number of milliseconds since January 1, 1970?) To provide nicer timestamps (such as “10 minutes ago”), you will add a module called moment. Install it using npm and save it as a development dependency:

npm install --save-dev moment

Each of your messages stores its timestamp as a data attribute. Write an init method for ChatList that calls the built-in function setInterval, which takes two arguments: a function to run and how often that function should be run. Your function will update each message with a human-readable timestamp.

To set the timestamp string, use jQuery in dom.js to find all ...

Get Front-End Web Development: The Big Nerd Ranch Guide 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.