ISO 8601
The international standard for representing dates and times in an unambiguous, machine-readable format.
Whether you're building APIs, storing timestamps in databases, or exchanging data between systems, ISO 8601 ensures everyone interprets dates and times the same way—regardless of locale, language, or timezone.
No confusion between MM/DD and DD/MM formats
Alphabetical sort equals chronological sort
Works across all languages and regions
Includes timezone information when needed
FORMAT BUILDER
Configure your ISO 8601 format and see it applied to the current time
YYYY-MM-DDThh:mm:ssZFORMAT SUMMARY
Complete overview of ISO 8601 date and time representations
ISO 8601 defines two format styles: basic (compact, no separators) and extended (human-readable, with separators). Both are valid and can represent the same information. The extended format is more common in APIs and user interfaces, while the basic format saves space in storage and transmission.
| TYPE | BASIC | EXAMPLE | EXTENDED | EXAMPLE | ||
|---|---|---|---|---|---|---|
| Calendar date | YYYYMMDD | ... | YYYY-MM-DD | ... | ||
| Ordinal date | YYYYDDD | ... | YYYY-DDD | ... | ||
| Week date | YYYYWwwD | ... | YYYY-Www-D | ... | ||
| Local time | hhmmss | ... | hh:mm:ss | ... | ||
| UTC time | hhmmssZ | ... | hh:mm:ssZ | ... | ||
| Time with offset | hhmmss±hhmm | ... | hh:mm:ss±hh:mm | ... | ||
| Date and time | YYYYMMDDThhmmssZ | ... | YYYY-MM-DDThh:mm:ssZ | ... | ||
| Duration | PnYnMnDTnHnMnS | P3Y6M4DT12H30M5S | PnYnMnDTnHnMnS | P3Y6M4DT12H30M5S | ||
| Time interval | start/end | ... | start/end | ... |
Use basic format when storage space or bandwidth matters, such as in filenames, log files, or compact data serialization. Fewer characters, same information.
Use extended format for APIs, databases, and anywhere humans need to read the data. The separators make it much easier to parse visually.
CALENDAR DATE
Representation of dates using the Gregorian calendar
The calendar date format is the most commonly used date representation. It follows a year-month-day order, which is unambiguous regardless of locale. Unlike regional formats (12/02/2024 could mean December 2nd or February 12th), ISO 8601 dates have only one possible interpretation.
COMPLETE REPRESENTATION
LIVE EXAMPLE
TRUNCATED REPRESENTATIONS
When full precision isn't needed, you can omit smaller units:
ISO 8601 uses big-endian order (largest unit first), similar to how we write numbers. Just as 1234 means one thousand, not four thousand, 2024-12-02 unambiguously means year 2024, month 12, day 02. This order also enables simple alphabetical sorting to produce chronological order.
TIME OF DAY
24-hour clock representations for time values
ISO 8601 uses the 24-hour clock (also called military time), eliminating the ambiguity of AM/PM. Midnight is 00:00:00, noon is 12:00:00, and 11 PM is 23:00:00. Times are written from largest unit (hours) to smallest (seconds or fractions).
LOCAL TIME
DECIMAL FRACTIONS
For sub-second precision, add a decimal fraction to the smallest unit. ISO 8601 prefers comma as the decimal separator, but period is also accepted and more common in programming.
REDUCED PRECISION
Omit seconds or minutes when not needed:
BASIC FORMAT
Compact form without colons:
DATE-TIME
Combine date and time with T separator:
TIME BUILDER
Configure your time format options and see the live result
hh:mm:ssZThe Z suffix (from "Zulu" in NATO phonetic alphabet) explicitly indicates UTC.
TIME ZONES & UTC
Coordinated Universal Time and timezone offset designators
A time without timezone information is ambiguous—"3 PM" means different moments depending on where you are. ISO 8601 solves this by appending a timezone designator that specifies the offset from UTC. For timestamps that need to be unambiguous globally (like API responses or log entries), always include the timezone.
UTC DESIGNATOR
The suffix Z (from "Zulu" in the NATO phonetic alphabet) indicates UTC. It's equivalent to +00:00 but more concise. Use Z for UTC timestamps in APIs and databases.
OFFSET FORMAT
LIVE OFFSET EXAMPLES
The same instant in time, represented with different timezone offsets:
| ZONE | OFFSET | 14:30:00 UTC = |
|---|---|---|
| UTC | Z | 14:30:00Z |
| UTC+0 | +00:00 | 14:30:00+00:00 |
| EST (UTC-5) | -05:00 | ...-05:00 |
| IST (UTC+5:30) | +05:30 | ...+05:30 |
| JST (UTC+9) | +09:00 | ...+09:00 |
| NZST (UTC+12) | +12:00 | ...+12:00 |
ISO 8601 uses numeric offsets, not timezone names like "EST" or "PST". This is intentional—offsets are unambiguous, while names can be ambiguous (CST could be Central Standard Time or China Standard Time) and change with daylight saving.
Store and transmit timestamps in UTC (with Z suffix), then convert to local time for display. This avoids daylight saving complications and makes comparison straightforward.
WEEK DATE
Representation using ISO week-numbering year and week number
Week dates are useful when you care more about "which week" than "which month"—common in business planning, project scheduling, and payroll systems. The ISO week system ensures every week has exactly 7 days and belongs to exactly one year, avoiding the split weeks that occur at month boundaries.
WEEK DATE FORMAT
ISO WEEK RULES
The ISO week system has specific rules that differ from some regional conventions:
- ▸Weeks start on Monday (not Sunday)
- ▸Week 01 contains the first Thursday of the year
- ▸Equivalently, Week 01 contains January 4th
- ▸Years have either 52 or 53 weeks
LIVE EXAMPLE
The ISO week-numbering year may differ from the calendar year near December/January. For example, December 30, 2024 (Monday) is actually 2025-W01-1 because that week contains the first Thursday of 2025. Conversely, January 1, 2021 was 2020-W53-5. Always use the ISO week year, not the calendar year, when working with week dates.
ORDINAL DATE
Representation using year and day-of-year number
Ordinal dates express a date as the day number within a year (1-365 or 1-366 for leap years). This format is compact and makes it easy to calculate the number of days between dates within the same year. It's widely used in astronomy, aviation, and military contexts where day-counting simplifies operations.
ORDINAL DATE FORMAT
- • Astronomy: Julian dates and star catalogs
- • Aviation: Flight planning and maintenance logs
- • Manufacturing: Batch and lot numbering
- • Military: Operations planning (often called "Julian dates")
CONVERSION TABLE (2024)
Converting between calendar and ordinal dates for the current year:
Although often called "Julian dates" colloquially, ISO 8601 ordinal dates are different from astronomical Julian dates. The astronomical Julian date is a continuous count of days since January 1, 4713 BC, used primarily in astronomy. ISO 8601 ordinal dates restart at 001 each year.
DURATION
Representation of spans of time
Durations represent a length of time rather than a specific point in time. They're useful for expressing things like "3 hours", "2 weeks", or "1 year, 6 months, and 15 days". All durations begin with the letter P (for "period"), and time components are separated from date components by T.
DURATION FORMAT
EXAMPLES
Only include the units you need. Omit any with zero value:
WEEK DURATION
Weeks can only be used alone—you cannot mix weeks with other units:
Note that M means different things before and after the T: P2M is 2 months, but PT2M is 2 minutes. The T separator is what distinguishes them. Similarly, P1D is 1 day, while PT24H is 24 hours (which may not equal 1 day during daylight saving transitions).
DURATION BUILDER
Set the values for each unit to build your ISO 8601 duration string
P0DTIME INTERVALS
Representation of time periods between two points
Intervals represent a span of time—useful for expressing date ranges, booking periods, or subscription terms. ISO 8601 supports four ways to express an interval: start/end, start/duration, duration/end, or duration alone. All use a forward slash (/) as the separator.
START AND END
When you know both the start and end dates:
START AND DURATION
When you know when it starts and how long it lasts:
DURATION AND END
When you know when it ends and how long it lasts:
DURATION ONLY
When context provides the start or end point:
RECURRING INTERVALS
For events that repeat, prefix the interval with R followed by an optional count. If no count is given, the recurrence is unbounded (repeats forever).
ISO 8601 doesn't specify whether interval endpoints are inclusive or exclusive. Convention varies by application—document your choice clearly when it matters.
Intervals can use full datetime values, not just dates. For example: 2024-12-02T09:00:00Z/2024-12-02T17:00:00Z represents working hours.
HISTORY & ADOPTION
Development timeline and global implementation
EDITION TIMELINE
RELATED STANDARDS
- RFC 3339Internet date/time format (profile of ISO 8601)
- ISO 8601-2:2019Extensions (uncertain dates, seasons, etc.)
- W3C NOTE-datetimeW3C profile for web applications
- EDTFExtended Date/Time Format (Library of Congress)
ADOPTION
ISO 8601 has been adopted as a national standard in numerous countries and is mandated or recommended by:
The ISO 8601 format has achieved notable cultural recognition, including endorsement by the webcomic XKCD in comic #1179, which humorously advocates for the standard as the only sensible date format for avoiding ambiguity.
PROGRAMMING REFERENCE
How to format and parse ISO 8601 dates in popular languages
Examples show common ISO 8601 formatting operations including full datetime, date only, time only, week dates, durations, and parsing. Output examples show typical values for December 2, 2024 at 14:30:00 UTC.
JAVASCRIPT
new Date().toISOString()new Date().toISOString().split('T')[0]new Date().toLocaleString('sv-SE')date.toISOString().replace('T', ' ').slice(0, 19)new Date('2024-12-02T14:30:00Z')new Date(1701528600000).toISOString()PYTHON
datetime.now(UTC).isoformat()date.today().isoformat()datetime.now().time().isoformat()datetime.now().isoformat(timespec='seconds')date.today().isocalendar()datetime.fromisoformat('2024-12-02T14:30:00')isodate.duration_isoformat(timedelta(hours=2))JAVA
Instant.now().toString()LocalDate.now().toString()LocalTime.now().toString()OffsetDateTime.now().toString()LocalDate.now().format(DateTimeFormatter.ISO_WEEK_DATE)Duration.ofHours(2).toString()Period.of(1, 2, 3).toString()Instant.parse('2024-12-02T14:30:00Z')C#
DateTime.UtcNow.ToString("o")DateTime.Now.ToString("s")DateTime.Now.ToString("yyyy-MM-dd")DateTime.UtcNow.ToString("u")DateTimeOffset.Now.ToString("o")XmlConvert.ToString(TimeSpan.FromHours(2))DateTime.Parse("2024-12-02T14:30:00Z")GO
time.Now().UTC().Format(time.RFC3339)time.Now().Format(time.RFC3339Nano)time.Now().Format("2006-01-02")time.Now().Format("15:04:05")time.Now().Format("2006-01-02T15:04:05-07:00")time.Parse(time.RFC3339, "2024-12-02T14:30:00Z")RUST
Utc::now().to_rfc3339()Utc::now().format("%Y-%m-%d").to_string()Utc::now().format("%Y-%m-%dT%H:%M:%S%.3fZ")Utc::now().to_rfc3339_opts(SecondsFormat::Secs, true)iso8601::duration::Duration::parse("PT2H30M")DateTime::parse_from_rfc3339("2024-12-02T14:30:00Z")RUBY
Time.now.utc.iso8601Time.now.iso8601(3)Date.today.iso8601Time.now.xmlschemaTime.now.strftime("%Y-%m-%dT%H:%M:%S%:z")2.hours.iso8601Time.iso8601("2024-12-02T14:30:00Z")PHP
date('c')date(DATE_ATOM)date('Y-m-d')gmdate('Y-m-d\TH:i:s\Z')date('o-\WW-N')(new DateTime())->format(DateTime::ATOM)(new DateInterval('PT2H30M'))->format('PT%hH%iM')new DateTime('2024-12-02T14:30:00Z')SWIFT
ISO8601DateFormatter().string(from: Date())fmt.formatOptions = [.withInternetDateTime, .withFractionalSeconds]fmt.formatOptions = [.withFullDate]fmt.formatOptions = [.withTime]df.dateFormat = "yyyy-MM-dd'T'HH:mm:ssZZZZZ"Measurement(value: 2, unit: UnitDuration.hours)ISO8601DateFormatter().date(from: "2024-12-02T14:30:00Z")KOTLIN
Instant.now().toString()LocalDateTime.now().toString()LocalDate.now().toString()ZonedDateTime.now().toString()LocalDate.now().format(DateTimeFormatter.ISO_WEEK_DATE)Duration.ofHours(2).toString()Instant.parse("2024-12-02T14:30:00Z")C/C++
strftime(buf, sizeof(buf), "%Y-%m-%dT%H:%M:%SZ", gmtime(&t))strftime(buf, sizeof(buf), "%Y-%m-%d", localtime(&t))strftime(buf, sizeof(buf), "%H:%M:%S", localtime(&t))strftime(buf, sizeof(buf), "%Y-%m-%dT%H:%M:%S%z", localtime(&t))strftime(buf, sizeof(buf), "%G-W%V-%u", localtime(&t))std::format("{:%FT%TZ}", std::chrono::system_clock::now())strptime("2024-12-02T14:30:00", "%Y-%m-%dT%H:%M:%S", &tm)DART
DateTime.now().toUtc().toIso8601String()DateTime.now().toIso8601String()DateFormat('yyyy-MM-dd').format(DateTime.now())DateFormat("yyyy-MM-dd'T'HH:mm:ss").format(dt)Duration(hours: 2, minutes: 30).toString()DateTime.parse("2024-12-02T14:30:00Z")ELIXIR
DateTime.utc_now() |> DateTime.to_iso8601()DateTime.to_iso8601(dt, :extended)Date.utc_today() |> Date.to_iso8601()Time.utc_now() |> Time.to_iso8601()NaiveDateTime.utc_now() |> NaiveDateTime.to_iso8601()Timex.Duration.to_string(Timex.Duration.from_hours(2))DateTime.from_iso8601("2024-12-02T14:30:00Z")R
format(Sys.time(), "%Y-%m-%dT%H:%M:%SZ", tz="UTC")format(Sys.Date(), "%Y-%m-%d")format(Sys.time(), "%Y-%m-%dT%H:%M:%S%z")format(Sys.Date(), "%G-W%V-%u")lubridate::format_ISO8601(now())as.POSIXct("2024-12-02T14:30:00Z", format="%Y-%m-%dT%H:%M:%SZ")PERL
strftime("%Y-%m-%dT%H:%M:%SZ", gmtime())strftime("%Y-%m-%d", localtime())strftime("%Y-%m-%dT%H:%M:%S%z", localtime())DateTime->now->iso8601()DateTime->now(time_zone => 'UTC')->strftime('%FT%TZ')DateTime::Duration->new(hours => 2)->iso8601()Time::Piece->strptime($str, "%Y-%m-%dT%H:%M:%S")SCALA
Instant.now.toStringLocalDateTime.now.toStringLocalDate.now.toStringZonedDateTime.now.toStringLocalDateTime.now.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME)Duration.ofHours(2).toStringInstant.parse("2024-12-02T14:30:00Z")HASKELL
formatTime defaultTimeLocale "%Y-%m-%dT%H:%M:%SZ" tformatTime defaultTimeLocale "%Y-%m-%d" dayformatTime defaultTimeLocale "%Y-%m-%dT%H:%M:%S%z" ztiso8601Show utcTimeformatTime defaultTimeLocale "%G-W%V-%u" dayparseTimeM True defaultTimeLocale "%Y-%m-%dT%H:%M:%SZ" strMost languages produce RFC 3339 output, which is a strict profile of ISO 8601 designed for internet timestamps. RFC 3339 requires a full date-time with timezone, while ISO 8601 allows many more variations.
Native ISO 8601 duration support varies by language. Java, Ruby, and .NET have built-in support. For others, consider libraries like isodate (Python),iso8601 (Rust), or Timex (Elixir).