# ISO Time with Microseconds

Key: `datetime.time.iso`

24-hour time with microsecond precision. Common in high-frequency data, scientific instruments, and log files.

Page: <https://meridian.online/docs/projects/finetype/types/datetime/time/iso>

Format: `%H:%M:%S.%f`

Samples: `10:30:00.123456`, `23:59:59.000000`

## Background

### Origin

ISO 8601 is maintained by the International Organization for Standardization and was first published in 1988.[[1]](https://en.wikipedia.org/wiki/ISO_8601) ISO 8601 writes a time of day in its extended format as hh:mm:ss, with colons between the hours, minutes and seconds.[[1]](https://en.wikipedia.org/wiki/ISO_8601) ISO 8601 allows a decimal fraction to be added to the lowest order time element of a time representation.[[1]](https://en.wikipedia.org/wiki/ISO_8601) ISO 8601 accepts either a comma or a full stop as the decimal mark between the seconds and their fraction.[[1]](https://en.wikipedia.org/wiki/ISO_8601) ISO 8601:2004 preferred the comma as the decimal mark.[[1]](https://en.wikipedia.org/wiki/ISO_8601) ISO 8601 sets no limit on the number of decimal places, but the number of decimal places needs to be agreed by the communicating parties.[[1]](https://en.wikipedia.org/wiki/ISO_8601)

RFC 3339 grammar writes a partial time as hour, minute and second separated by colons, optionally followed by a full stop and one or more digits of fractional seconds.[[2]](https://www.rfc-editor.org/rfc/rfc3339) RFC 3339 describes fractions of a second as its only rarely used option.[[2]](https://www.rfc-editor.org/rfc/rfc3339)

### Use

Python's datetime library defines the %f directive as the microsecond as a decimal number, zero-padded to 6 digits.[[3]](https://docs.python.org/3/library/datetime.html) Python's time.isoformat writes HH:MM:SS.ffffff when the microsecond is not 0, and HH:MM:SS when it is 0.[[3]](https://docs.python.org/3/library/datetime.html) Python's strptime accepts from one to six digits for %f and zero pads them on the right.[[3]](https://docs.python.org/3/library/datetime.html) Python's time.fromisoformat accepts fractional seconds with any number of digits, truncating anything beyond 6.[[3]](https://docs.python.org/3/library/datetime.html)

PostgreSQL's time type stores a time of day with a resolution of 1 microsecond.[[4]](https://www.postgresql.org/docs/current/datatype-datetime.html) PostgreSQL allows a precision of 0 to 6 fractional digits in the seconds field of a time value.[[4]](https://www.postgresql.org/docs/current/datatype-datetime.html) DuckDB's TIME type holds the hour, minute, second and microsecond of a day, and a separate TIME\_NS type holds nanosecond precision.[[5]](https://duckdb.org/docs/current/sql/data_types/time.html) DuckDB's documentation recommends that most applications use the TIMESTAMP types, keeping TIME for rare cases where the date part can be disregarded.[[5]](https://duckdb.org/docs/current/sql/data_types/time.html) Before casting values with more than six fractional digits to a microsecond type, decide whether the extra precision matters to you. (Meridian's view) A time of day with no date or offset cannot be placed on a timeline by itself, so look for a companion date column and a stated time zone before treating these values as moments. (Meridian's view)

## Sources

1. [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) — secondary source
2. [RFC 3339: Date and Time on the Internet: Timestamps \| RFC Editor](https://www.rfc-editor.org/rfc/rfc3339) — standard
3. [datetime — Basic date and time types — Python 3.15.0 documentation](https://docs.python.org/3/library/datetime.html) — documentation
4. [PostgreSQL: Documentation: 18: 8.5. Date/Time Types](https://www.postgresql.org/docs/current/datatype-datetime.html) — documentation
5. [Time Types – DuckDB](https://duckdb.org/docs/current/sql/data_types/time.html) — documentation
