# Unix timestamp: seconds, ms, µs or ns

4 types, told apart by digit count: 10, 13, 16 and 19.

How to tell a Unix timestamp in seconds from one in milliseconds, microseconds or nanoseconds: digit counts, the dates each reading gives, and the rules finetype uses.

Page: <https://meridian.online/docs/projects/finetype/types/told-apart/epoch-units>

## The types

| Type | Key | Unit | Digits | Pattern | DuckDB transform | Sample |
| --- | --- | --- | --- | --- | --- | --- |
| [Unix Timestamp (seconds)](https://meridian.online/docs/projects/finetype/types/datetime/epoch/unix_seconds) | `datetime.epoch.unix_seconds` | Seconds | 10 | `^\d{10}$` | `to_timestamp({col}::BIGINT)` | `1705312200` |
| [Unix Timestamp (milliseconds)](https://meridian.online/docs/projects/finetype/types/datetime/epoch/unix_milliseconds) | `datetime.epoch.unix_milliseconds` | Milliseconds | 13 | `^\d{13}$` | `to_timestamp({col}::BIGINT / 1000)` | `1705312200000` |
| [Unix Timestamp (microseconds)](https://meridian.online/docs/projects/finetype/types/datetime/epoch/unix_microseconds) | `datetime.epoch.unix_microseconds` | Microseconds | 16 | `^\d{16}$` | `to_timestamp({col}::BIGINT / 1000000)` | `1705312200000000` |
| [Unix Epoch Nanoseconds](https://meridian.online/docs/projects/finetype/types/datetime/timestamp/epoch_nanoseconds) | `datetime.timestamp.epoch_nanoseconds` | Nanoseconds | 19 | `^\d{19}$` | `make_timestamp_ns({col}::BIGINT)` | `1705325400000000000` |

## Read in each unit

Each type's first registry sample, decoded in every unit. The bold reading is the type's own.

| Sample | Seconds | Milliseconds | Microseconds | Nanoseconds |
| --- | --- | --- | --- | --- |
| Unix Timestamp (seconds) `1705312200` | **2024-01-15 09:50:00 UTC** | 1970-01-20 17:41:52.2 UTC | 1970-01-01 00:28:25.3122 UTC | 1970-01-01 00:00:01.7053122 UTC |
| Unix Timestamp (milliseconds) `1705312200000` | after 9999 | **2024-01-15 09:50:00 UTC** | 1970-01-20 17:41:52.2 UTC | 1970-01-01 00:28:25.3122 UTC |
| Unix Timestamp (microseconds) `1705312200000000` | after 9999 | after 9999 | **2024-01-15 09:50:00 UTC** | 1970-01-20 17:41:52.2 UTC |
| Unix Epoch Nanoseconds `1705325400000000000` | after 9999 | after 9999 | after 9999 | **2024-01-15 13:30:00 UTC** |

## How finetype tells them apart

From finetype 0.6.66's source.

finetype's datetime format reader reads a 10-digit integer as Unix seconds, a 13-digit integer as milliseconds, a 16-digit integer as microseconds and a 19-digit integer as nanoseconds.[[1]](https://github.com/meridian-online/finetype/blob/v0.6.66/crates/finetype-core/src/datetime_format.rs#L304-L322) The reader picks a format only when at least 95% of the column's sampled non-null values match it.[[2]](https://github.com/meridian-online/finetype/blob/v0.6.66/crates/finetype-core/src/datetime_format.rs#L46-L47)[[3]](https://github.com/meridian-online/finetype/blob/v0.6.66/crates/finetype-core/src/datetime_format.rs#L424-L438) For these four formats the reader checks the digit count alone, not the date a value would decode to.[[1]](https://github.com/meridian-online/finetype/blob/v0.6.66/crates/finetype-core/src/datetime_format.rs#L304-L322)[[4]](https://github.com/meridian-online/finetype/blob/v0.6.66/crates/finetype-core/src/datetime_format.rs#L108-L110)

finetype's source describes a bare 10-digit integer as possibly an epoch, an identifier or a phone number, so it applies an epoch reading only when its model has already given the column a datetime type.[[5]](https://github.com/meridian-online/finetype/blob/v0.6.66/crates/finetype-core/src/datetime_format.rs#L20-L29)[[6]](https://github.com/meridian-online/finetype/blob/v0.6.66/crates/finetype-model/src/column/mod.rs#L2041-L2059) finetype applies that reading only when at least 90% of the column's non-empty sampled values pass the chosen type's own validation rule.[[7]](https://github.com/meridian-online/finetype/blob/v0.6.66/crates/finetype-model/src/column/mod.rs#L2063-L2075)[[8]](https://github.com/meridian-online/finetype/blob/v0.6.66/crates/finetype-model/src/column/mod.rs#L461-L484)

Column names such as epoch, unix timestamp, epoch time and posix time point finetype to seconds, and epoch ms, unix ms and epoch milliseconds point it to milliseconds.[[9]](https://github.com/meridian-online/finetype/blob/v0.6.66/crates/finetype-model/src/column/header_sharpen.rs#L563-L571) A column name that no earlier header rule claims and that contains epoch or unix points to milliseconds when it also contains ms or milli, and to seconds when it does not.[[10]](https://github.com/meridian-online/finetype/blob/v0.6.66/crates/finetype-model/src/column/header_sharpen.rs#L871-L877) finetype declines a seconds or milliseconds hint from a column name when there are at least three non-empty values and 10% or fewer of them pass that type's validation rule.[[11]](https://github.com/meridian-online/finetype/blob/v0.6.66/crates/finetype-model/src/column/mod.rs#L504-L514)[[12]](https://github.com/meridian-online/finetype/blob/v0.6.66/crates/finetype-model/src/column/mod.rs#L1675-L1720)

Where the digit count and the column name disagree, decode a few values and check the dates against something you already know about the data. (Meridian's view)

## What finetype's evaluation shows

The evaluation report in finetype's repository at release 0.6.66 measured release 0.6.60 on 2026-09-23.[[13]](https://github.com/meridian-online/finetype/blob/v0.6.66/eval/eval_output/report.md#L1-L5) The report says its tables are generated by a separate tool that has drifted from the SQL harness it claims to mirror, and that a figure taken from it for publication must be its SQL headline.[[14]](https://github.com/meridian-online/finetype/blob/v0.6.66/eval/eval_output/report.md#L7) Until finetype publishes a measurement for each type, this page gives no figure for how often it mistakes one unit for another. (Meridian's view)

## Who writes each unit

### [Seconds](https://meridian.online/docs/projects/finetype/types/datetime/epoch/unix_seconds)

Python's time.time() returns the time in seconds since the epoch as a floating-point number.[[15]](https://docs.python.org/3/library/time.html) RFC 7519 defines the JSON Web Token NumericDate as a JSON numeric value representing the number of seconds from 1970-01-01T00:00:00Z UTC, ignoring leap seconds.[[16]](https://www.rfc-editor.org/rfc/rfc7519) Stripe's API reference describes the created attribute of a Charge as measured in seconds since the Unix epoch.[[17]](https://docs.stripe.com/api/charges/object)

### [Milliseconds](https://meridian.online/docs/projects/finetype/types/datetime/epoch/unix_milliseconds)

JavaScript's Date.now() returns the number of milliseconds elapsed since the epoch.[[18]](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now) Elasticsearch stores dates internally as a long number representing milliseconds since the epoch.[[19]](https://www.elastic.co/docs/reference/elasticsearch/mapping-reference/date) Binance's spot REST API documentation states that all time and timestamp related fields in its JSON responses are in milliseconds by default.[[20]](https://developers.binance.com/docs/binance-spot-api-docs/rest-api/general-api-information)

### [Microseconds](https://meridian.online/docs/projects/finetype/types/datetime/epoch/unix_microseconds)

The Zipkin API specification describes a span's timestamp as epoch microseconds of the start of the span.[[21]](https://github.com/openzipkin/zipkin-api/blob/master/zipkin2-api.yaml) BigQuery's UNIX\_MICROS function returns the number of microseconds since 1970-01-01 00:00:00 UTC.[[22]](https://docs.cloud.google.com/bigquery/docs/reference/standard-sql/timestamp_functions)

### [Nanoseconds](https://meridian.online/docs/projects/finetype/types/datetime/timestamp/epoch_nanoseconds)

Go's time package documents UnixNano as returning a time as the number of nanoseconds elapsed since January 1, 1970 UTC.[[23]](https://pkg.go.dev/time) OpenTelemetry's Metrics Data Model records the time a value was sampled in a field called time\_unix\_nano.[[24]](https://opentelemetry.io/docs/specs/otel/metrics/data-model/) pandas converts integer epoch times with to\_datetime, and its default unit is nanoseconds.[[25]](https://pandas.pydata.org/docs/user_guide/timeseries.html)

## Sources

1. [finetype 0.6.66, datetime\_format.rs](https://github.com/meridian-online/finetype/blob/v0.6.66/crates/finetype-core/src/datetime_format.rs#L304-L322) — FineType
2. [finetype 0.6.66, datetime\_format.rs](https://github.com/meridian-online/finetype/blob/v0.6.66/crates/finetype-core/src/datetime_format.rs#L46-L47) — FineType
3. [finetype 0.6.66, datetime\_format.rs](https://github.com/meridian-online/finetype/blob/v0.6.66/crates/finetype-core/src/datetime_format.rs#L424-L438) — FineType
4. [finetype 0.6.66, datetime\_format.rs](https://github.com/meridian-online/finetype/blob/v0.6.66/crates/finetype-core/src/datetime_format.rs#L108-L110) — FineType
5. [finetype 0.6.66, datetime\_format.rs](https://github.com/meridian-online/finetype/blob/v0.6.66/crates/finetype-core/src/datetime_format.rs#L20-L29) — FineType
6. [finetype 0.6.66, column/mod.rs](https://github.com/meridian-online/finetype/blob/v0.6.66/crates/finetype-model/src/column/mod.rs#L2041-L2059) — FineType
7. [finetype 0.6.66, column/mod.rs](https://github.com/meridian-online/finetype/blob/v0.6.66/crates/finetype-model/src/column/mod.rs#L2063-L2075) — FineType
8. [finetype 0.6.66, column/mod.rs](https://github.com/meridian-online/finetype/blob/v0.6.66/crates/finetype-model/src/column/mod.rs#L461-L484) — FineType
9. [finetype 0.6.66, header\_sharpen.rs](https://github.com/meridian-online/finetype/blob/v0.6.66/crates/finetype-model/src/column/header_sharpen.rs#L563-L571) — FineType
10. [finetype 0.6.66, header\_sharpen.rs](https://github.com/meridian-online/finetype/blob/v0.6.66/crates/finetype-model/src/column/header_sharpen.rs#L871-L877) — FineType
11. [finetype 0.6.66, column/mod.rs](https://github.com/meridian-online/finetype/blob/v0.6.66/crates/finetype-model/src/column/mod.rs#L504-L514) — FineType
12. [finetype 0.6.66, column/mod.rs](https://github.com/meridian-online/finetype/blob/v0.6.66/crates/finetype-model/src/column/mod.rs#L1675-L1720) — FineType
13. [finetype evaluation report (release 0.6.60)](https://github.com/meridian-online/finetype/blob/v0.6.66/eval/eval_output/report.md#L1-L5) — FineType
14. [finetype evaluation report (release 0.6.60)](https://github.com/meridian-online/finetype/blob/v0.6.66/eval/eval_output/report.md#L7) — FineType
15. [time — Time access and conversions](https://docs.python.org/3/library/time.html) — documentation
16. [RFC 7519: JSON Web Token (JWT)](https://www.rfc-editor.org/rfc/rfc7519) — standard
17. [The Charge object](https://docs.stripe.com/api/charges/object) — organisation
18. [Date.now() - JavaScript \| MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now) — documentation
19. [Date field type](https://www.elastic.co/docs/reference/elasticsearch/mapping-reference/date) — documentation
20. [General REST API Information \| Binance Developer Docs](https://developers.binance.com/docs/binance-spot-api-docs/rest-api/general-api-information) — organisation
21. [zipkin-api/zipkin2-api.yaml at master · openzipkin/zipkin-api · GitHub](https://github.com/openzipkin/zipkin-api/blob/master/zipkin2-api.yaml) — documentation
22. [Timestamp functions \| BigQuery \| Google Cloud Documentation](https://docs.cloud.google.com/bigquery/docs/reference/standard-sql/timestamp_functions) — documentation
23. [time package - time - Go Packages](https://pkg.go.dev/time) — documentation
24. [Metrics Data Model](https://opentelemetry.io/docs/specs/otel/metrics/data-model/) — documentation
25. [Time series / date functionality](https://pandas.pydata.org/docs/user_guide/timeseries.html) — documentation
