Unix Timestamp Code Examples
Ready-to-use code snippets for getting the current Unix timestamp, converting timestamps to dates, and converting dates to timestamps in 16+ programming languages.
16
Languages
3
Operations Each
48
Total Snippets
1-Click
Copy to Clipboard
Language Guides
Most commonly used
JavaScriptFull guide
// Get current Unix timestamp (seconds)
const timestamp = Math.floor(Date.now() / 1000);
console.log(timestamp); // e.g., 1706745600
// Get timestamp in milliseconds
const timestampMs = Date.now();PythonFull guide
import time
from datetime import datetime
# Get current Unix timestamp
timestamp = int(time.time())
print(timestamp) # e.g., 1706745600
# Using datetime
timestamp = int(datetime.now().timestamp())TypeScriptFull guide
// Get current Unix timestamp (seconds)
const timestamp: number = Math.floor(Date.now() / 1000);
console.log(timestamp); // e.g., 1706745600
// Get timestamp in milliseconds
const timestampMs: number = Date.now();Frequently Asked Questions
About Unix Timestamps
A Unix timestamp (also known as Epoch time or POSIX time) represents the number of seconds that have elapsed since January 1, 1970, at 00:00:00 UTC.
This format is universally used in programming because it's timezone-independent, easy to compare, and compact to store. Most languages provide built-in functions to work with Unix timestamps.
Timezone Independent
Easy to Compare
Compact Storage
Universal Standard