This repository was archived by the owner on Jun 2, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 56
$.time_ago()
Arthur Guiot edited this page Aug 10, 2017
·
1 revision
Do you have a web app with "time-related" elements (like blog posts or objects in a timeline)?
If yes, this funtion is for you 😊!
Basically, this function will from a given time generate a string like:
2 days agoYesterday10 minutes from now...
This is very simple, you only need to give it a new Date() object.
JS:
var aDay = 24 * 60 * 60 * 1000;
console.log($.time_ago(new Date(Date.now() - aDay))); // Yesterday
console.log($.time_ago(new Date(Date.now() - aDay * 2))); // 2 days agoYou even can use the $.dynamic() function with it to have a realtime render.
- Home
- The Core Languages
- Getting Started: Installation
- The Basics (
$.var()+$.target()) - Developing for DisplayJS
-
$.select()- Text related
- If...else
$.xss()$.repeat()$.custom()$.live()$.load()$.on()$.onEvent()$.ready()- Scroll API
$.all()$.clone()$.is()$.valEmpty()$.remove()$.show()&$.hide()$.ajax()- Class Related
$.css()$.getStyle()- Fade effects
$.extend()$.dynamic()$.parent()- Elements-Nodes
$.component()$.time_ago()$.copy()$.then()$.sleep()$.getProp()