Skip to content

Tag: javascript

Seconds ago in JavaScript

A couple of weeks ago I needed a way to convert a number of seconds to a more user friendly format for a project I’m working on. I’ve seen these called “ago” functions. They take a raw number of seconds and convert it to something friendly like “3 seconds ago” or “5 minutes ago.” Not quite what I wanted though. I was looking for something that counted seconds up to a minute and then minutes and seconds after that. For what I need, it wouldn’t ever go past minutes.