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:

FormatExampleDescriptionUse Cases
Unix Seconds1704067200Seconds since Unix epoch (10 digits)Databases, APIs, system logs
Unix Milliseconds1704067200000Milliseconds since Unix epoch (13 digits)JavaScript, event tracking, high-precision timing
ISO 8601 (UTC)2024-01-01T00:00:00ZStandard format with Z suffix for UTCJSON APIs, data interchange, web standards
ISO 8601 (with offset)2024-01-01T00:00:00-05:00Standard format with timezone offsetLocal time display, calendar systems
RFC 2822Mon, 01 Jan 2024 00:00:00 +0000Internet message formatEmail headers, HTTP headers
ISO 8601 Date Only2024-01-01Date without time componentScheduling, date comparisons, reporting

Common Timezone Offsets from UTC

Standard time offsets for major timezones (note: DST may add +1 hour during summer months):

TimezoneAbbreviationUTC OffsetDST OffsetMajor Cities
Pacific TimePST/PDTUTC-8UTC-7Los Angeles, San Francisco, Seattle
Mountain TimeMST/MDTUTC-7UTC-6Denver, Phoenix, Salt Lake City
Central TimeCST/CDTUTC-6UTC-5Chicago, Houston, Mexico City
Eastern TimeEST/EDTUTC-5UTC-4New York, Toronto, Miami
Greenwich Mean TimeGMT/BSTUTC+0UTC+1London, Dublin, Lisbon
Central European TimeCET/CESTUTC+1UTC+2Paris, Berlin, Rome
Eastern European TimeEET/EESTUTC+2UTC+3Athens, Helsinki, Cairo
India Standard TimeISTUTC+5:30-Mumbai, Delhi, Bangalore
China Standard TimeCSTUTC+8-Beijing, Shanghai, Hong Kong
Japan Standard TimeJSTUTC+9-Tokyo, Osaka, Kyoto
Australian Eastern TimeAEST/AEDTUTC+10UTC+11Sydney, Melbourne, Brisbane

DateTime Libraries by Programming Language

Recommended libraries and built-in modules for handling timestamps in popular languages:

LanguageBuilt-inRecommended LibraryKey Features
JavaScriptDateLuxon, date-fnsTimezone-aware, immutable, modern API
Pythondatetimependulum, arrowHuman-friendly API, automatic DST handling
Javajava.time-Modern API (Java 8+), immutable types, thread-safe
C#DateTime, DateTimeOffsetNodaTimeComprehensive timezone support, period calculations
PHPDateTimeCarbonFluent API, localization, human-readable formatting
RubyTimeActiveSupport::TimeWithZoneRails integration, timezone helpers
Gotime-Built-in timezone support, Duration type
Rust-chronoType-safe, timezone-aware, zero-cost abstractions
SwiftDate-Foundation framework, Calendar API
Kotlinjava.timekotlinx-datetimeMultiplatform 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

  1. Store in UTC: Always store timestamps in UTC (Unix time or ISO 8601 with Z suffix) to avoid timezone ambiguity
  2. Convert on Display: Convert to local timezone only when displaying to users
  3. Use 64-bit Integers: Avoid the Year 2038 problem by using 64-bit integers for timestamps
  4. Include Timezone Info: When storing local times, always include timezone offset or identifier
  5. Test DST Transitions: Always test your datetime code around daylight saving time boundaries
  6. Use Standard Formats: Prefer ISO 8601 for data interchange and Unix timestamps for storage
  7. Avoid String Manipulation: Use proper datetime libraries instead of string parsing
  8. 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:

Have questions? Check out our FAQ page for quick answers to common timestamp questions.