Zum Inhalt springen
uencoder

Konvertieren between timezones correctly

Timezone Konvertierung ist tricky due in DST, abbreviations, und political changes. Lernen in verwenden IANA timezone names und der Instant/ZonedDateTime Muster.

  1. 1

    Best practices: (1) Store timestamps in UTC. (2) Use IANA timezone names (America/New_York, not EST/EDT — abbreviations are ambiguous). (3) Convert to local time only for display. (4) Use a library (date-fns-tz, Luxon, js-joda) that supports IANA timezones. (5) Never use Date for timezone math — JavaScript Date is broken for timezones. (6) Be aware of DST transitions (2 AM becomes 3 AM in spring, 2 AM repeats in fall).

  2. 2
    Zeitzonen-Konverter →

    a timestamp from one timezone to another. Specify the source and target IANA timezone names (e.g., America/New_York in Asia/Tokyo). The tool handles DST transitions correctly. Always use IANA names, not abbreviations (EST could be US Eastern or Australian Eastern) konvertieren

  3. 3
    Zeitstempel-Konverter →

    Abrufen the current UTC timestamp. Store this in databases, APIs, and logs. UTC is universal — no DST, no political changes. Convert to local time only at the presentation layer. Use ISO 8601 format (2024-01-15T10:30:00Z) for storage and exchange.

  4. 4
    Datums-Rechner →

    Berechnen date differences across timezones. Be careful: "add 1 day" in UTC may cross a DST boundary in local time, resulting in 23 or 25 hours. Use date-based arithmetic (add days, not hours) when the intent is calendar-based, and time-based arithmetic (add hours) when the intent is duration-based.

Häufige Fragen

Why are timezone abbreviations ambiguous?
EST is both US Eastern Standard Time (UTC-5) and Australian Eastern Standard Time (UTC+10). CST is US Central, China Standard, and Cuba Standard Time. IANA names (America/New_York, Asia/Shanghai) are unambiguous. Always use IANA names for storage and computation; use abbreviations only for display.
How do I handle DST transitions?
Spring forward: 2 AM becomes 3 AM — times between 2 and 3 AM do not exist. Fall back: 2 AM becomes 1 AM — times between 1 and 2 AM occur twice. For scheduling, use UTC to avoid ambiguity. For display, a good library will show which occurrence (before or after the transition) you mean. Never schedule events at 2:30 AM — it may not exist or may be ambiguous.

Workflows, die diese Aufgabe lösen

Verwandte Tools