Time-Ago Pill
Overview
- Shows a date as a relative phrase such as today, 3d ago, or in 5d
- Compares the date to the current day automatically
- Colors the pill green for today, warm for past, and blue for upcoming
- Reads far more naturally than a raw date in a status list
- A blank date simply shows a dash, so empty rows never look broken
- Applied as column-formatting JSON on a date field, so it changes nothing about the underlying data
Common Use Cases
- Last updated or last reviewed on a document list
- Due or start dates on tasks
- Recent activity on a tracker
- Follow-up dates on a CRM-style list
- Expiry or renewal timing
- Any date where recency or nearness matters more than the exact day
Details
- Design Pattern: Dates & Time
- Format Scope: Column
Required Columns
| Display name | Column type | Internal name |
|---|---|---|
| Document | Single line of text | [Title] |
| Updated | Date and time | [Updated] |
Prerequisites
- Build a list with these columns before you paste the JSON.
- Then populate the list with dates.
- Because the JSON is applied at the column level, the Updated column can use any name you want.
- The phrasing and colors are computed against the current day – no extra setup is needed.
- Because the label is computed against today’s date, it depends on your tenant time zone and the time of day – test close to midnight.
How to Apply JSON code
- On the Updated column, open the column header menu, choose Column settings, then Format this column.
- Switch to Advanced mode.
- Paste the JSON below and click Save.
JSON Code
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"style": {
"display": "flex",
"align-items": "center",
"justify-content": "flex-start",
"height": "100%"
},
"children": [
{
"elmType": "span",
"txtContent": "=if(@currentField == '', '-', if(abs(((Number(Date(@currentField)) - Number(@now)) / 86400000)) < 1, 'today', if(((Number(Date(@currentField)) - Number(@now)) / 86400000) < 0, if(indexOf(((abs(((Number(Date(@currentField)) - Number(@now)) / 86400000))) + ''), '.') < 0, ((abs(((Number(Date(@currentField)) - Number(@now)) / 86400000))) + ''), substring(((abs(((Number(Date(@currentField)) - Number(@now)) / 86400000))) + ''), 0, indexOf(((abs(((Number(Date(@currentField)) - Number(@now)) / 86400000))) + ''), '.'))) + ' d ago', 'in ' + if(indexOf(((abs(((Number(Date(@currentField)) - Number(@now)) / 86400000))) + ''), '.') < 0, ((abs(((Number(Date(@currentField)) - Number(@now)) / 86400000))) + ''), substring(((abs(((Number(Date(@currentField)) - Number(@now)) / 86400000))) + ''), 0, indexOf(((abs(((Number(Date(@currentField)) - Number(@now)) / 86400000))) + ''), '.'))) + ' d')))",
"style": {
"display": "inline-block",
"padding": "6px 14px",
"border-radius": "14px",
"font-size": "13px",
"font-weight": "700",
"line-height": "17px",
"text-align": "center",
"white-space": "nowrap",
"color": "=if(@currentField == '', '#475569', if(abs(((Number(Date(@currentField)) - Number(@now)) / 86400000)) < 1, '#0c9e52', if(((Number(Date(@currentField)) - Number(@now)) / 86400000) < 0, '#bf5b00', '#1d4ed8')))",
"background-color": "=if(@currentField == '', '#e6eaf0', if(abs(((Number(Date(@currentField)) - Number(@now)) / 86400000)) < 1, '#ccf5de', if(((Number(Date(@currentField)) - Number(@now)) / 86400000) < 0, '#ffe9cf', '#d6e4ff')))"
}
}
]
}
Common Questions About the Time-Ago Pill
What is the Time-Ago Pill built with?
It is built with a standard Microsoft List (SharePoint list) and a small piece of column-formatting JSON. There is no custom development, no SPFx solution, and no third-party tools. It is the kind of clean, maintainable formatting Greg Zelfond builds for teams that want a date column that reads as a friendly relative phrase without ongoing development overhead.
What columns does it need?
It needs one Date column, where the JSON is applied, plus any label column such as the document name. The phrase is computed from that date against the current day.
Does this design use any custom development or third-party tools?
No. It uses only out-of-the-box SharePoint column formatting, which Microsoft supports natively. That keeps it stable and easy to maintain, and nothing breaks when SharePoint is updated. Out-of-the-box is the only way Greg builds, so you can own and extend the design yourself for years.
If LookBook 365 is code-free and out-of-the-box, why does this example include JSON?
Because SharePoint formatting JSON is not custom code – it is a native configuration feature built into lists and libraries. It is declarative: it only describes how an existing column looks, and cannot run scripts, reach external services, or change your data. Nothing is deployed and nothing breaks when Microsoft updates SharePoint, and you can edit or remove it anytime. That is why LookBook 365 treats it as out-of-the-box and low risk.
How does it know what today is?
It uses the current date built into SharePoint, so the phrase stays correct every day without any refresh or extra column.
Can Greg build a design like this for our lists?
Yes – this is exactly the kind of work Greg Zelfond does. As an independent SharePoint consultant and Microsoft MVP, he designs out-of-the-box list and library formatting like this so your team can read and maintain it without a developer. Reach out through the contact page to talk about your lists.
