A complete Unix timestamp cheat sheet with quick formulas, conversions, and shortcuts for developers. Save time with ready-to-use snippets.
Turn concepts into action with our free developer tools. Validate payloads, encode values, and test workflows directly in your browser.
Sumit
Full Stack MERN Developer
Building developer tools and SaaS products
Sumit is a Full Stack MERN Developer focused on building reliable developer tools and SaaS products. He designs practical features, writes maintainable code, and prioritizes performance, security, and clear user experience for everyday development workflows.
When you're working with time in development, speed matters. You don’t always want to Google how to convert a timestamp or calculate durations. That’s where a Unix timestamp cheat sheet becomes incredibly useful.
In this guide, you’ll get a complete, practical, and developer-focused cheat sheet for Unix timestamps—covering formulas, quick conversions, code snippets, and real-world shortcuts.
For instant conversions while working, use this tool: https://www.mydevtoolhub.com/tools/unix-timestamp-converter
A Unix timestamp is the number of seconds since January 1, 1970 (UTC).
Example:
1700000000Math.floor(Date.now() / 1000);
new Date(timestamp * 1000);
Math.floor(new Date(date).getTime() / 1000);
const oneDay = Math.floor(Date.now() / 1000) + 86400;
const sevenDaysAgo = Math.floor(Date.now() / 1000) - (7 * 86400);
function isExpired(expiry) {
return Math.floor(Date.now() / 1000) > expiry;
}
function isAfter(t1, t2) {
return t1 > t2;
}
function format(ts) {
return new Date(ts * 1000).toISOString();
}
{
createdAt: Math.floor(Date.now() / 1000)
}
const now = Math.floor(Date.now() / 1000);
db.logs.find({
createdAt: { $gte: now - 86400 }
});
db.logs.find().sort({ createdAt: -1 });
GET /api/posts?after=1700000000
{
"createdAt": 1700000000
}
new Date(timestamp * 1000).toLocaleString();
const remaining = target - Math.floor(Date.now() / 1000);
console.log({
timestamp,
iso: new Date(timestamp * 1000).toISOString()
});
if (timestamp.toString().length === 13) {
console.log("Milliseconds");
}
// Fix
Math.floor(Date.now() / 1000);
Solution:
// Avoid
"1700000000"
// Use
1700000000
const expiry = now + 3600;
const cacheExpiry = now + 300;
const last30Days = now - (30 * 86400);
Never rely on local time.
Improves database performance.
Avoid strings.
Use it for:
Avoid for:
Use this tool:
https://www.mydevtoolhub.com/tools/unix-timestamp-converter
Because JavaScript uses milliseconds.
Yes, for dates before 1970.
This Unix timestamp cheat sheet is designed to save you time and improve your productivity. Instead of repeatedly searching for conversions and formulas, you now have everything in one place.
Use these shortcuts, snippets, and best practices in your daily development workflow to build faster and more reliable applications.
For instant conversions and debugging, use:
https://www.mydevtoolhub.com/tools/unix-timestamp-converter
Bookmark this guide and use it whenever you're working with time-related logic.
Struggling with messy spreadsheet data? Learn how to enforce clean, validated inputs using Google Sheet Form Generator.
Streamline HR operations using Google Sheets and automated forms. Simplify hiring, onboarding, and employee workflows without coding.
Compare Google Sheet Form Generator vs Google Forms. Discover which tool is better for developers, automation, and scalable workflows.