[23] Unix time は、 Unix 系システムを中心に多くの計算機システムで用いられている日時の内部表現形式 (整数時刻系) です。 計算機システム用の時刻系としては最も著名なものです。
[79] 現在ではキリスト紀元 (西暦年) やグレゴリオ暦を遥かに凌ぐ、 世界で最もよく用いられている日時形式と考えられます。
[25] Unix time は、時刻の表現の方法の1つです。 Unix epoch から経過した秒単位の時間を数として表したものです。
[124]
Unix time には安定した呼称がなく、
ほかに
POSIX time,
time_t
,
epoch秒,
epoch time,
epoch,
Unix epoch
などとも呼ばれます。
[131] 通常は秒を単位とした数値ですが、 10n 倍したミリ秒Unix time やナノ秒Unix timeがあります。
[109] Unix time の元期 (Unix epoch、The Epoch) は、 西暦1970年1月1日0時0分0秒 (UTC) です。
[95] いわゆる Unix time は、いろいろな方法で表現されます。表現方法によって、 記述可能な値域 (最古の日時から最大の日時までの範囲) や粒度 (秒、ミリ秒等の時間的解像度) が変わります。 具体的には言語・プロトコルの章を参照。
[7] 負の値 (以前) は、環境や文脈によっては扱えないことがあります。 最近は多くの環境が負の値も扱えるようになっているようです。
[88] Unix time には様々な場面で使われていますが、使われる場面によっては、 日時を表す以外の値が割り当てられることがあります。
[72] mktime
や time
は算出不能時に値 -1
を返します。
[70] 西暦1970年を扱う必要がない場合に、値 0 が「日時指定なし」など特別な意味を割り当てられることがあります。
[89] 当然のことながら、こうした特殊な値を使う場面と、 これらを使わずに0や負数を日時の表現として使う場面とで、 取扱いを誤ると混乱が生じます。
[37] time_t
は整数とするのが普通ですが、
それ以外では拡張して秒未満も含めた小数のUnix time
を使うことがよくあります。
[99] Unix time の秒は、 UTC の秒と考えられています。
[15]
Unix time では閏秒は考えません。
[67] POSIX は1日の秒数を固定長としつつ、 実際の時刻との対応は未定義、実装定義とし >>10、閏秒の処置は曖昧にしています。 実装は leap smear などにより閏秒が存在しないものとして扱っています。
[69] right/
のような Unix システムで閏秒を扱う試みもありましたが、
Unix time との整合性を維持できず失敗しました。
[83] Unix time は UTC での Unix epoch からの経過時間を表しています。
[84] どこのどんな地方時 (標準時、サマータイム) を使っていて、それが UTC どどれだけの時差があるのであっても、 その時差情報は Unix time に含めることはできません。 Unix time はどの瞬間であるかだけを表します。
[104] 非常に多くのプラットフォーム (OS、プログラミング言語、 ライブラリー、プロトコル、アプリケーションなど) が Unix time を採用しています。
[105] Unix time という実質的に同じ日時の表現でありながらも、 各プラットフォームごとにいろいろなデータ型や構文が採用されています。 定義の方法としても、 POSIX の定義を参照するものもあれば、同等のものを独自に定義するものもあります。 厳密に定義するものもあれば、行間を読むことが期待される曖昧なものもあります。
[106] 呼称も様々です。
[6] C言語はデータ型 (typedef
) time_t を有しています >>65。
ISO C はその値の精度や値域を定めていません >>65 が、
現在では実質すべての実装が POSIX の定める Epoch すなわち
>>18 からの経過秒数
(Seconds Since the Epoch) >>10 の整数としています。
1970年未満については未定義としています >>10。
伝統的には32ビット符号なし整数でしたが、
2038年問題があり64ビット符号なし整数への移行が進んでいます >>66。
[68]
C言語は更に構造体 timespec
を定めています。 timespec
は
非負の time_t
の値を持つ tv_sec
と、
[ 0, 999999999 ] の long
値を持つ tv_nsec
の組で構成されます。ナノ秒精度の時刻の表現に使われます。 >>65
time.t
[11]
Perlにおける日時はプラットフォーム依存ですが、
ほとんどすべての場合 Unix time です。
場合によって小数の Unix time も使われます。
[71]
Ruby の Time
は Unix time
を使っています。値域はプラットフォーム依存です。
Time
[74] RFC 2783 - Pulse-Per-Second API for UNIX-like Operating Systems, Version 1.0, , https://tools.ietf.org/html/rfc2783#section-2
The value returned by time is the offset in seconds from 01-JAN-1970 00:00:00 (just like the CRTL's times() routine), in order to make life easier for code coming in from the POSIX/Unix world.
[114] NFS の timeval
, nfstime3
は、
Unix time の seconds
とミリ秒数の useconds
の構造体です。
>>113
[55] gzip の MTIME は、 Unix time を小エンディアンの 4バイト符号無し整数で表したものです。
A time field is an unsigned four-octet number containing the number of seconds elapsed since midnight, 1 January 1970 UTC.
[13]
RFC 4871 が定義する DKIM-Signature:
頭欄の t=
タグの値は、
1970年1月1日0時0分0秒 (UTC) からの秒数とされています。
ただし、閏秒は数えません。 RFC 4871 は、
実装に対して最低 1012 (≒ 紀元後20万年、≒ 40ビット符号無し整数)
までの値を扱えることを推奨 (SHOULD) しています。
更に、サービス拒否攻撃防止のために、
12桁以上の値は無限大とみなして構わない
(MAY) ともしています。
[31] SQL では時間帯を持たない日時のデータ型が使われることも多いですが、 その場合でも Unix time が使われることがあります。ここでの Unix time は、本来の 1970年1月1日0時 UTC からの秒数ではなく、 地方時のからの秒数とされています。
[20] MySQL では、 UNIX_TIMESTAMP
で日時を Unix time に、
FROM_UNIXTIME
で Unix time を日時に変換できます。
[2] oauth_timestamp
も Unix time 同等の定義となっています。
Its value is a JSON number representing the number of seconds from 1970-01-01T0:0:0Z as measured in UTC until the date/time.
A time value expressed in seconds since the UNIX epoch (i.e., zero hours, zero minutes, zero seconds, on January 1, 1970) Coordinated Universal Time (UTC) [POSIX].
Type: Integer
Example time representing 09:00:00 01/01/2000 UTC: 946717200
A JSON number, seconds since the UNIX epoch (00:00:00 UTC on 1 January 1970).
- gmt_unix_time
- The current time and date in standard UNIX 32-bit format (seconds since the midnight starting Jan 1, 1970, UTC, ignoring leap seconds) according to the sender's internal clock. Clocks are not required to be set correctly by the basic TLS protocol; higher-level or application protocols may define additional requirements. Note that, for historical reasons, the data element is named using GMT, the predecessor of the current worldwide time base, UTC.
[126] BinaryTime は、 RFC 4049 で規定された ASN.1の日時形式の一種で、 Unix time を使っています。 >>125
[116] MessagePack は、 Timestamp extension type を定めています。 ビット長の異なる3種類があります。 >>82
[117] 秒はいずれも Unix time。ナノ秒は [0, 999999999]。 仕様書に符号化・復号の方法が定められていますが、 ナノ秒に不正な値が与えられた時の検査は何もされていません。 >>82 これは意図したものであるようですが >>121、 その意図は不明です。 実装が厳密に検査するか否か、秒と秒未満を分けて保持するかどうかで、 挙動が変わってきそうで、 相互運用性・セキュリティー等の問題の温床にならないか懸念されます。
[73] msgpack/spec.md at master · msgpack/msgpack () https://github.com/msgpack/msgpack/blob/master/spec.md#timestamp-extension-type
Tag value 1 is for numerical representation of seconds relative to 1970-01-01T00:00Z in UTC time. (For the non-negative values that the Portable Operating System Interface (POSIX) defines, the number of seconds is counted in the same way as for POSIX “seconds since the epoch” [TIME_T].) The tagged item can be a positive or negative integer (major types 0 and 1), or a floating-point number (major type 7 with additional information 25, 26, or 27). Note that the number can be negative (time before 1970-01-01T00:00Z) and, if a floating-point number, indicate fractional seconds.
Tag value 1 is for numerical representation of seconds relative to
1970-01-01T00:00Z in UTC time. (For the non-negative values that the
Portable Operating System Interface (POSIX) defines, the number of
seconds is counted in the same way as for POSIX "seconds since the
epoch" [TIME_T].) The tagged item can be a positive or negative
integer (major types 0 and 1), or a floating-point number (major type
7 with additional information 25, 26, or 27). Note that the number
can be negative (time before 1970-01-01T00:00Z) and, if a floating-
point number, indicate fractional seconds.
[111] DSSSL:
JIS X 4153:1998 8.5.11
「
[141] , http://www.y-adagio.com/public/standards/jis_dsssl/cls8.txt
(time) (time->string k) (time->string k boolean)手続きtimeは,1970年1月1日午前0時0分秒(GMT)から経過した秒数を整数として返す。手続きtime->stringは,手続きtimeが返す日付及び時間の整数表現をISO 8601の形式の文字列に変換する。引数booleanが存在し,それが真の場合,文字列表現はGMTに基づくものとなり,その他の場合に地方時間を示す。
LHA では内部的にタイムスタンプを 1970-01-01 00:00:00 UTC からの通算秒 に変換しています。このため、実在しないスタンプ(80-00-00 など)を持った ファイルを格納した場合、タイムスタンプは不定となります。
[62] しかし保存先は MS-DOSの日時形式らしい。
03h DWORD 最終更新日時 (time_t形式)
When converting from system-dependent time_t format to the 32-bit
unsigned MTIME format used in gzip files, if a timestamp does not
fit gzip now substitutes zero instead of the timestamp's low-order
32 bits, as per Internet RFC 1952. When converting from MTIME to
time_t format, if a timestamp does not fit gzip now warns and
substitutes the nearest in-range value instead of crashing or
silently substituting an implementation-defined value (typically,
the timestamp's low-order bits). This affects timestamps before
1970 and after 2106, and timestamps after 2038 on platforms with
32-bit signed time_t. [bug present since the beginning]
NumericDate
A JSON numeric value representing the number of seconds from
1970-01-01T00:00:00Z UTC until the specified UTC date/time,
ignoring leap seconds. This is equivalent to the IEEE Std 1003.1,
2013 Edition [POSIX.1] definition "Seconds Since the Epoch", in
which each day is accounted for by exactly 86400 seconds, other
than that non-integer values can be represented.
API パラメータでは、UNIX Time(1970年1月1日からの経過秒数)を指定する箇所と、YYYYMMDD のようなフォーマットの文字列形式で指定する箇所がありますが、いずれも UTC で指定します。
[110] GNU Coreutils: 28.9 Unix 紀元 (the Epoch) からの秒数 (, ) https://linuxjm.osdn.jp/info/GNU_coreutils/coreutils-ja_207.html
日付情報はUNIX Epoch(e.g.
1592528400
)
3.99 time
A monotonically increasing value generated by a node. Time (0.0) starts at 00:00:00 GMT January 1, 1970.
Time (0.0) is equivalent to 00:00:00 GMT January 1, 1970. Absolute times are specified in SFTime or MFTime fields as double-precision floating point numbers representing seconds. Negative absolute times are interpreted as happening before 1970.
[92] VRML97, ISO/IEC 14772-1:1997 -- 5 Field and Event Reference () https://www.web3d.org/documents/specifications/14772/V2.0/part1/fieldsRef.html#SFTime
The time at which the current rate limit window resets in UTC epoch seconds.
When providing Unix timestamps enter seconds[.nanoseconds], where seconds is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT), not counting leap seconds (aka Unix epoch or Unix time), and the optional .nanoseconds field is a fraction of a second no more than nine digits long.
ACCESS-NONCE 毎リクエストごとに増加する必要のある正の整数。通常はUNIXタイムスタンプを用います。最大値は 9223372036854775807 です。APIキーごとに管理されます。
Git internal format
It is <unix timestamp> <time zone offset>, where <unix timestamp> is the number of seconds since the UNIX epoch. <time zone offset> is a positive or negative offset from UTC. For example CET (which is 1 hour ahead of UTC) is +0100.
[137] Java などで単位をミリ秒とするミリ秒Unix timeが使われています。
[136] BSON のUTC datetimeがミリ秒Unix time です。 MongoDB Extended JSON の日付の一種もミリ秒Unix timeです。
[14] Java の Calendar
>>27 や
JavaScript の Date
の値も Unix time
と同じ元期ですが、ミリ秒単位となっています。 (こちらも閏秒は考えません。)
[24] DOM の日時を扱う API (DOMTimeStamp
) も、
ミリ秒単位の千倍 Unix time を用いています。
[46] DateTime Wire Format でも使われています。
time, in milliseconds since 00:00:00 UTC on 1 January 1970
特定の時点は、1970 年 1 月 1 日 00:00:00.000 GMT (グレゴリオ暦) を元期とするミリ秒単位のオフセットで表現できます。
[30] File API () https://w3c.github.io/FileAPI/#UnixEpoch
タイムスタンプ型の値は64ビットの符号付き整数としてエンコードされ、エポックとして知られる標準基準時間(1970年1月1日、GMT時間0時0分0秒)からのミリ秒数を表します。
定期購読の有効期限が、1970年1月1日 00:00:00 GMTからのミリ秒単位で表されています。
ASN.1フィールドタイプ:1708
ASN.1フィールド値: IA5STRING(RFC 3339の日付として解釈されます)
JSONフィールド名:expires_date
JSONフィールド値:数値
具体的には、1970年1月1日 00:00:00 GMTからのミリ秒数を表すlong値として表現されています。この原稿では、これを便宜的に「エポックからのミリ秒」と呼ぶことにします。なお、1970年1月1日 00:00:00 GMTについてJava言語APIでは、「エポック」と呼んでいます。
[54] Make Event's timeStamp use DOMHighResTimeStamp (majido著, ) https://github.com/whatwg/dom/commit/912d58746bc4c67c2fd210124639f7c34991fce5
time = xsd:decimal
The absolute time for this timestamp, in milliseconds since 1 January 1970 00:00:00 UTC.
Required: no, Default: none.
[129] DateTimeOffset.ToUnixTimeMilliseconds メソッド (System) | Microsoft Docs (dotnet-bot, ) https://docs.microsoft.com/ja-jp/dotnet/api/system.datetimeoffset.tounixtimemilliseconds?view=net-6.0#System_DateTimeOffset_ToUnixTimeMilliseconds
[138] Go言語などで単位をナノ秒とするナノ秒Unix timeが使われています。
[149] Date nanoseconds field type | Elasticsearch Guide [8.11] | Elastic, , https://www.elastic.co/guide/en/elasticsearch/reference/current/date_nanos.html
The
date_nanos
data type stores dates in nanosecond resolution, which limits its range of dates from roughly 1970 to 2262, as dates are still stored as a long representing nanoseconds since the epoch.
[34] Go の Time
は、ナノ秒単位の Unix time
を用いています。
The zero value of type Time is January 1, year 1, 00:00:00.000000000 UTC.
UnixNano returns t as a Unix time, the number of nanoseconds elapsed since January 1, 1970 UTC.
[100] tantek は短縮URL で Unix epoch からの経過日数を New Base 60 で記述し、 epoch days と呼んでいます。 >>101
After that I use a 3 digit sexagesimal (Base60) number to represent the date in a manner deliberately limited to human individuals. Why Base60? Lots of reasons, including print-safety (as mentioned above). Want to read the entire derivation and reasons why? See NewBase60 (includes open source CASSIS implementation).
Why 3 sexagesimal digits to represent the date? It turns out that 3 sexagesimal digits are capable of representing over 500 years of days - plenty overengineered for any human lifetime. And if anyone does figure out how to live more than 500 years I have a feeling that person will not only not resemble human as we know it very much, but will either have bigger problems to deal with than URL shortener limitations, or will be so smart that they will come up with a better solution.
But for now, for our feeble less than 200 year lifetimes, this is good enough. In addition we can even agree on a day zero that computes well with existing platforms. Unix Epoch start: 1970-01-01. Given that no-one published anything to the web before 1990, I think we're ok with that. What happens in a few hundred years? Perhaps people can pick their own day zeroes as they see fit.
Thus the 3 characters after the "t" represent the number of days since 1970-01-01 in sexagesimal - what I'm calling "epoch days".
[150] std::chrono::system_clock - cppreference.com, , https://en.cppreference.com/w/cpp/chrono/system_clock
The epoch of system_clock
is unspecified, but most implementations use Unix Time (i.e., time since 00:00:00 Coordinated Universal Time (UTC), Thursday, 1 January 1970, not counting leap seconds).(until C++20) system_clock
measures Unix Time (i.e., time since 00:00:00 Coordinated Universal Time (UTC), Thursday, 1 January 1970, not counting leap seconds).(since C++20)
[151] >>150
std::chrono::seconds
を使うと秒数になり、
std::chrono::days
を使うと日数になります。
[132] Unix epoch を元期とし、月を単位とする日時系がいくつかあります。
[133] ミリ秒Unix timeなどとは違って、暦月を単位とした数え方は通常の Unix time の倍数ではないことに注意が必要です。暦月は月ごとに長さが違うので、 通常の Unix time とそのまま相互変換することができません。
[139] Unix epoch を 0 とするグレゴリオ月単位の数え方: HTML月数
[140] Unix epoch を 0 とする朔望月単位の数え方: 月時計
[76] Unix time の値を保存するデータ型次第で、日時桁溢れ問題が発生します。
[8] iPhoneを「1970年1月1日」に設定すると利用不能になる問題、Appleがソフト更新で解消へ - ITmedia ニュース ( 版) http://www.itmedia.co.jp/news/articles/1602/16/news132.html
[9] iPhoneで「1970年1月1日」に設定すると使用不能に? 実際に試してみた - ITmedia Mobile ( 版) http://www.itmedia.co.jp/mobile/articles/1602/12/news125.html
[144] Unix time の10進表現はに9桁で表現できなくなりました。 前年のの西暦2000年問題に関連して危険日としてよく紹介されていました (西暦2001年9月9日問題)。 大きな問題は報告されていません。 >>143, >>142
[157] Windows Meに2001年9月9日問題 | スラド, https://srad.jp/story/01/06/12/0626230/
2001年9月9日1時46分40秒にこの数字が十進数で9桁から10桁に変わりました。2chなどではこの数字を掲示板のidに使用しているため、この前後での掲示板の並べ替えがうまく行きません。
[87] 9月 9日 コンピュータの9月9日問題が発生(2001年)(ブルーバックス編集部) | ブルーバックス | 講談社 () https://gendai.ismedia.jp/articles/-/66915
[59]
西暦2038年問題は、
Unix time
の桁溢れ問題です。
に Unix time が32ビット整数で表現できなくなること、
およびそれに起因する諸問題であります。
[75] 西暦2038年問題の次は西暦2106年問題とされます。
[148] Time formatting and storage bugs - Wikipedia, , https://en.wikipedia.org/wiki/Time_formatting_and_storage_bugs#Year_2106
Many existing file formats, communications protocols, and application interfaces employ a variant of the Unix
time_t
date format, storing the number of seconds since the Unix Epoch (midnight UTC, 1 January 1970) as an unsigned 32-bit binary integer. This value will roll over on 7 February 2106 at 06:28:15. That is, at this time the number of seconds since 1 January 1970 is FFFF FFFF in hex.
[152] Time formatting and storage bugs - Wikipedia, , https://en.wikipedia.org/wiki/Time_formatting_and_storage_bugs#Year_2286
Systems that use a string of length 10 characters to record the Unix time may have problems reporting times beyond the ten-billionth second after 20 November 2286, at 17:46:40.
[77] 西暦2486年問題
UNIX時間は,例外的にClassic Mac OSなど一部の古いシステムでは,UTC1904年1月1日00:00:00が紀元になることがあります。
[47] UNIX時間と称しているが、実際には 1904 time system のこと。
[1] スラッシュドット ジャパン | 明日でepochから2^30秒 http://slashdot.jp/article.pl?sid=04/01/08/172200&mode=flat&commentsort=4&threshold=-1
[16] time_t - Wikipedia ( ( 版)) http://ja.wikipedia.org/wiki/Time_t
[17] Unix time - Wikipedia, the free encyclopedia ( ( 版)) http://en.wikipedia.org/wiki/Unix_time
[36] SANS Digital Forensics and Incident Response Blog | Understanding EXT4 (Part 2): Timestamps | SANS Institute () https://digital-forensics.sans.org/blog/2011/03/14/digital-forensics-understanding-ext4-part-2-timestamps
[39] Add PushSubscription.expirationTime (#248) (beverloo著, ) https://github.com/w3c/push-api/commit/73da6411aac80de7de9bf5e65ee8eb4cc6a9aa24
[40] Epoch (astronomy) - Wikipedia () https://en.wikipedia.org/wiki/Epoch_(astronomy)
[41] General Concepts () http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_16
Amazon Redshift の EPOCH の実装は、サーバーのあるタイムゾーンから独立した 1970-01-01 00:00:00.000000 に関連します。
[60] Unix time - Wikipedia () https://en.wikipedia.org/wiki/Unix_time
[80] Package google.protobuf | Protocol Buffers | Google Developers () https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.Timestamp
[112] Arthur David OlsonさんはTwitterを使っています 「It's Salute to the Seventies day at the @SSTransitCenter. Guess: a UNIX-derived computer operating on UTC drives this display and crashed 17 minutes before I captured this image. https://t.co/G3b12GQDue https://t.co/9Ze5qUN5ME」 / Twitter (午前4:22 · 2021年2月2日 , ) https://twitter.com/dashdashado/status/1356321947005628418