Timestamp & Timezone Reference
Quick reference guide for timestamp formats, timezone offsets, datetime libraries, and common timestamp conversions. Essential information for developers working with time-based data.
Key Definitions
What is a Unix Timestamp?
A Unix timestamp is the number of seconds that have elapsed since January 1, 1970, 00:00:00 UTC (the Unix epoch), not counting leap seconds. It represents an absolute point in time regardless of timezone.
What is ISO 8601?
ISO 8601 is an international standard for representing dates and times using the format YYYY-MM-DDTHH:mm:ss with optional timezone information (Z for UTC or ±HH:mm for offsets). It provides unambiguous, sortable, and machine-readable date-time strings.
What is Epoch Time?
Epoch time (or Unix epoch) refers to January 1, 1970, 00:00:00 UTC, the reference point from which Unix timestamps are counted. The term is often used interchangeably with "Unix timestamp" to mean the number of seconds since this starting point.
What is UTC?
UTC (Coordinated Universal Time) is the primary time standard by which the world regulates clocks and time. It is not affected by daylight saving time and serves as the reference point for all other timezones, which are expressed as offsets from UTC.
Timestamp Format Comparison
Common timestamp formats used in programming and APIs:
Format | Example | Description | Use Cases |
---|---|---|---|
Unix Seconds | 1704067200 | Seconds since Unix epoch (10 digits) | Databases, APIs, system logs |
Unix Milliseconds | 1704067200000 | Milliseconds since Unix epoch (13 digits) | JavaScript, event tracking, high-precision timing |
ISO 8601 (UTC) | 2024-01-01T00:00:00Z | Standard format with Z suffix for UTC | JSON APIs, data interchange, web standards |
ISO 8601 (with offset) | 2024-01-01T00:00:00-05:00 | Standard format with timezone offset | Local time display, calendar systems |
RFC 2822 | Mon, 01 Jan 2024 00:00:00 +0000 | Internet message format | Email headers, HTTP headers |
ISO 8601 Date Only | 2024-01-01 | Date without time component | Scheduling, date comparisons, reporting |
Common Timezone Offsets from UTC
Standard time offsets for major timezones (note: DST may add +1 hour during summer months):
Timezone | Abbreviation | UTC Offset | DST Offset | Major Cities |
---|---|---|---|---|
Pacific Time | PST/PDT | UTC-8 | UTC-7 | Los Angeles, San Francisco, Seattle |
Mountain Time | MST/MDT | UTC-7 | UTC-6 | Denver, Phoenix, Salt Lake City |
Central Time | CST/CDT | UTC-6 | UTC-5 | Chicago, Houston, Mexico City |
Eastern Time | EST/EDT | UTC-5 | UTC-4 | New York, Toronto, Miami |
Greenwich Mean Time | GMT/BST | UTC+0 | UTC+1 | London, Dublin, Lisbon |
Central European Time | CET/CEST | UTC+1 | UTC+2 | Paris, Berlin, Rome |
Eastern European Time | EET/EEST | UTC+2 | UTC+3 | Athens, Helsinki, Cairo |
India Standard Time | IST | UTC+5:30 | - | Mumbai, Delhi, Bangalore |
China Standard Time | CST | UTC+8 | - | Beijing, Shanghai, Hong Kong |
Japan Standard Time | JST | UTC+9 | - | Tokyo, Osaka, Kyoto |
Australian Eastern Time | AEST/AEDT | UTC+10 | UTC+11 | Sydney, Melbourne, Brisbane |
DateTime Libraries by Programming Language
Recommended libraries and built-in modules for handling timestamps in popular languages:
Language | Built-in | Recommended Library | Key Features |
---|---|---|---|
JavaScript | Date | Luxon , date-fns | Timezone-aware, immutable, modern API |
Python | datetime | pendulum , arrow | Human-friendly API, automatic DST handling |
Java | java.time | - | Modern API (Java 8+), immutable types, thread-safe |
C# | DateTime , DateTimeOffset | NodaTime | Comprehensive timezone support, period calculations |
PHP | DateTime | Carbon | Fluent API, localization, human-readable formatting |
Ruby | Time | ActiveSupport::TimeWithZone | Rails integration, timezone helpers |
Go | time | - | Built-in timezone support, Duration type |
Rust | - | chrono | Type-safe, timezone-aware, zero-cost abstractions |
Swift | Date | - | Foundation framework, Calendar API |
Kotlin | java.time | kotlinx-datetime | Multiplatform support, modern API |
Quick Conversion Reference
Seconds ⇄ Milliseconds
To milliseconds: multiply by 1,000
To seconds: divide by 1,000
Example: 1704067200 seconds = 1704067200000 milliseconds
Unix ⇄ Date Object
JavaScript: new Date(timestamp * 1000)
Python: datetime.fromtimestamp(timestamp)
Java: Instant.ofEpochSecond(timestamp)
Current Timestamp
JavaScript: Math.floor(Date.now() / 1000)
Python: int(time.time())
Java: Instant.now().getEpochSecond()
ISO 8601 ⇄ Unix
To Unix: Parse ISO string to Date, get epoch seconds
To ISO: Create Date from timestamp, format as ISO
Always convert to UTC first for consistency
Timestamp Best Practices
- Store in UTC: Always store timestamps in UTC (Unix time or ISO 8601 with Z suffix) to avoid timezone ambiguity
- Convert on Display: Convert to local timezone only when displaying to users
- Use 64-bit Integers: Avoid the Year 2038 problem by using 64-bit integers for timestamps
- Include Timezone Info: When storing local times, always include timezone offset or identifier
- Test DST Transitions: Always test your datetime code around daylight saving time boundaries
- Use Standard Formats: Prefer ISO 8601 for data interchange and Unix timestamps for storage
- Avoid String Manipulation: Use proper datetime libraries instead of string parsing
- Document Precision: Clearly specify whether timestamps are in seconds, milliseconds, or microseconds
Learn More
For comprehensive guides and in-depth tutorials, explore our learning center:
- Complete Guide to Unix Timestamps
- ISO 8601 Date-Time Format Explained
- Timezone Conversion Best Practices
- Working with Date-Time in JavaScript
- Python DateTime Complete Guide
Have questions? Check out our FAQ page for quick answers to common timestamp questions.