Ready to convert
Paste dates or timestamps and click Convert// convert timestamps to "2 hours ago" or "3 days from now"
Convert timestamps and dates to relative time format like "2 hours ago" or "3 days from now". Free browser-based tool, no signup required.
Ready to convert
Paste dates or timestamps and click ConvertEnter timestamps, ISO dates, Unix epoch values, or natural language like "yesterday" — one per line.
Select output style (long/short/narrow), precision level, and locale for localized output.
Copy individual results or all at once. Enable live mode to watch relative times tick in real time.
The Relative Time Formatter converts raw timestamps and ISO dates into human-friendly phrases like "2 hours ago", "3 days from now", or "last week". It uses the native Intl.RelativeTimeFormat API for accurate, locale-aware output — the same engine powering modern apps like Twitter, GitHub, and Slack.
The tool accepts ISO 8601 dates (2024-01-15T10:30:00), Unix timestamps in seconds or milliseconds (1700000000 or 1700000000000), common date strings (January 15, 2024), and relative expressions like "yesterday" or "now". One value per line for batch mode.
Enter a BCP 47 language tag like en, fr, de, ja, or zh. The output will be formatted in that language using the browser's built-in Intl.RelativeTimeFormat API — so "2 hours ago" becomes "il y a 2 heures" in French.
When enabled, the tool refreshes all relative times every second. This is useful when you want to watch a timestamp tick from "59 seconds ago" to "1 minute ago" in real time — perfect for testing time-sensitive UI logic.
Long: "2 hours ago" — full words. Short: "2 hr. ago" — abbreviated. Narrow: "2h ago" — minimal. Numeric: always uses numbers even for values like "tomorrow" → "in 1 day".
Auto precision picks the best unit (seconds → minutes → hours → days → months → years). Forcing a specific unit like "minutes" means a 3-hour difference shows as "180 minutes ago" instead of "3 hours ago" — useful for consistent UI formatting.
No. All conversion happens entirely in your browser using JavaScript's built-in Date and Intl APIs. Nothing is uploaded or stored anywhere.
A relative time formatter converts absolute timestamps — Unix epoch values, ISO 8601 strings, or plain date/time strings — into human-friendly, context-aware phrases. Instead of displaying "2024-11-14T13:45:00Z", a relative time formatter outputs something your users actually understand: "3 hours ago", "yesterday", "last Monday", or "in 2 weeks".
Relative timestamps are everywhere. Social media feeds, commit histories, notification systems, comment sections, log viewers — they all rely on relative time formatting to make raw data feel alive and meaningful. This tool gives you instant access to that formatting logic, powered by the browser's native Intl.RelativeTimeFormat API.
💡 Looking for premium web development assets? MonsterONE offers unlimited downloads of templates, UI kits, and developer assets — worth checking out.
The core logic is simple: calculate the difference in milliseconds between two moments (usually "now" and your target), then express that difference in the most appropriate time unit. A 90-second gap becomes "2 minutes ago", a 25-hour gap becomes "yesterday" or "1 day ago" depending on precision settings, and a 400-day gap becomes "about 1 year ago".
Modern implementations use the Intl.RelativeTimeFormat API (supported in all major browsers since 2020) to handle locale-aware output. This means the same code that produces "2 hours ago" in English outputs "il y a 2 heures" in French, "hace 2 horas" in Spanish, or "2時間前" in Japanese — without any custom translation work.
1700000000 — the standard format returned by most server-side APIs1700000000000 — used by JavaScript's Date.now()2024-11-14T13:45:00Z or 2024-11-14T13:45:00+05:30November 14, 2024, 2024-11-14, 11/14/2024now, yesterday, tomorrow (resolved against the current moment)The Intl.RelativeTimeFormat API provides three formatting styles that balance verbosity against space constraints:
Auto precision picks the most intuitive unit: differences under 45 seconds show as seconds, under 45 minutes as minutes, under 22 hours as hours, under 26 days as days, under 11 months as months, and beyond that as years. These thresholds are modeled after common UX conventions used by major apps.
Forcing a specific precision is useful when you need consistent units across a dataset. For example, forcing "hours" means a 2-day difference shows as "48 hours ago" — useful for SLA tracking or log analysis where you want uniform granularity regardless of magnitude.
Here's a basic implementation you can drop into any project:
function timeAgo(date) {
const rtf = new Intl.RelativeTimeFormat('en', { numeric: 'auto' });
const diff = (new Date(date) - Date.now()) / 1000;
const thresholds = [
{ unit: 'year', secs: 31536000 },
{ unit: 'month', secs: 2592000 },
{ unit: 'day', secs: 86400 },
{ unit: 'hour', secs: 3600 },
{ unit: 'minute', secs: 60 },
{ unit: 'second', secs: 1 },
];
for (const { unit, secs } of thresholds) {
if (Math.abs(diff) >= secs) {
return rtf.format(Math.round(diff / secs), unit);
}
}
return rtf.format(0, 'second');
}
Activity feeds and social timelines: Posts, comments, and events feel more engaging when displayed as "5 minutes ago" rather than a raw datetime string. Relative time creates the feeling of a live, active community.
Notification systems: Whether push notifications, in-app alerts, or email digests, relative timestamps help users immediately gauge urgency — "just now" versus "2 days ago" carries very different weight.
Log analysis and debugging: Server logs and API traces are full of Unix timestamps. Converting them to relative time lets you instantly see "this error happened 3 hours ago" without any mental arithmetic.
Build and deployment pipelines: CI/CD dashboards, commit histories, and release notes become much more scannable when you can see "deployed 47 minutes ago" instead of "2024-11-14 09:23:11 UTC".
Scheduled content and countdown timers: Future-facing relative time ("in 3 days", "in 2 weeks") is essential for content calendars, product launch countdowns, and event pages.
Always show the absolute timestamp on hover or in a tooltip — relative time loses meaning as time passes ("2 years ago" tells you very little about the exact date). For anything older than a week or two, consider switching to an abbreviated absolute date format like "Nov 14, 2024" instead.
Refresh relative timestamps periodically if your UI is long-lived (this tool's live mode demonstrates this). A timestamp that reads "2 minutes ago" when a user loads the page should read "10 minutes ago" if they're still looking at it eight minutes later.
Be careful with timezone assumptions. Always store and transmit timestamps in UTC, and let the client-side formatting handle localization. The Intl.RelativeTimeFormat API respects the user's local timezone automatically when you pass a proper UTC timestamp.