Timestamp Converter- Convert Unix timestamps to readable dates, calculate relative time, and generate JavaScript code instantly
JavaScript Code Examples
// Get current Unix timestamp (seconds) const timestamp = Math.floor(Date.now() / 1000); console.log(timestamp); // Output: 1785579804 // Get current Unix timestamp (milliseconds) const msTimestamp = Date.now(); console.log(msTimestamp); // Output: 1785579804000
// Convert Unix timestamp to Date object const timestamp = 1785579804; const date = new Date(timestamp * 1000); console.log(date.toISOString()); // "2026-07-30T17:56:44.000Z" console.log(date.toLocaleString()); // "7/30/2026, 5:56:44 PM"
// Convert Date to Unix timestamp const date = new Date('2024-01-15T10:30:00Z'); const timestamp = Math.floor(date.getTime() / 1000); console.log(timestamp); // 1705315800
// Convert Unix timestamp to different formats const ts = 1785579804; const date = new Date(ts * 1000); // ISO 8601 date.toISOString(); // "2026-07-30T17:56:44.000Z" // RFC 2822 date.toUTCString(); // "Thu, 30 Jul 2026 17:56:44 GMT" // Local string date.toLocaleDateString(); // "7/30/2026" date.toLocaleTimeString(); // "5:56:44 PM"
// Calculate relative time (time ago) function timeAgo(timestamp) { const seconds = Math.floor((Date.now() / 1000) - timestamp); const intervals = { year: 31536000, month: 2592000, week: 604800, day: 86400, hour: 3600, minute: 60 }; for (const [unit, secondsInUnit] of Object.entries(intervals)) { const interval = Math.floor(seconds / secondsInUnit); if (interval >= 1) return `${interval} ${unit}${interval > 1 ? 's' : ''} ago`; } return 'just now'; } console.log(timeAgo(1785579804)); // "2 minutes ago"
What can our Timestamp Converter do?
The free online timestamp converter is a powerful tool for developers, sysadmins and anyone who works with time-based data to instantly convert Unix timestamp to human-readable dates and vice versa. We make time conversion so simple whenever you’re debugging APIs, analyzing log files or scheduling events.
- Instant Conversion: Change unix timestamps to dates and vice versa, with real-time output as you type or select the dates.
- Full Timezone Support: Display the time in your own time zone, UTC and all major world time zones, including automatic DST support.
- JavaScript Examples: Have ready-to-go JavaScript snippets to convert timestamps in your projects.
- Batch Conversion: Convert multiple timestamps in one go. Ideal for analyzing log files or database dumps.
- Countdown Timer: Set a timer and watch a real-time countdown! Perfect for last minute events and up to the minute planning.
- Relative Time Calculator: See how much time has passed or will pass with natural language like “3 days ago” or “in 2 weeks”.
How to Use Our Timestamp Converter
Our timestamp converter is easy to use and simple to get started with. Here are some basic steps to follow:
- Enter your timestamp or date – Type a Unix timestamp (like 1785579804), ISO date (2024-01-15T10:30:00Z), or natural language (yesterday, Jan 15 2024)
- Set your timezone – set to local time, UTC or one of 25+ world timezones
- Click Convert – Instantly see your timestamp in all formats including seconds, milliseconds, ISO 8601, RFC 2822, and more
- Copy results – Any result can be copied to the clipboard with a single click!
- Generate code – Switch to the JavaScript tab to see ready to use code snippets
Understanding Unix Timestamps
A Unix timestamp (also Unix time, POSIX time or epoch time) is a representation of a moment in time as the number of seconds that have passed since 00:00:00 UTC on January 1, 1970 (also known as the Unix epoch). Unix timestamps are also integers, which computers can easily compare, sort and perform calculations on, unlike human readable dates.
Wikipedia states that the Unix timestamp ignores leap seconds and is commonly used in operating systems and file formats. How you usually store time in programming languages, databases and APIs.
| Time Unit | Seconds | Unix Timestamp Example |
|---|---|---|
| 1 Minute | 60 seconds | 60 |
| 1 Hour | 3,600 seconds | 3600 |
| 1 Day | 86,400 seconds | 86400 |
| 1 Week | 604,800 seconds | 604800 |
| 1 Month (30 days) | 2,592,000 seconds | 2592000 |
| 1 Year (365 days) | 31,536,000 seconds | 31536000 |
To learn more about date handling in JavaScript, look at the MDN Web Docs: Date objects in JavaScript.
Related Tools You May Like
Calculators | Converters | Games | Generators | Random | Web Tools | Developer Tools