This is an old revision of the document!
UNIX 時間は 1970年1月1日午前0時0分0秒を 0 として経過した秒数を示したものである.
多くの PC システム,ソフトウェア上で用いられている.
なお,うるう秒は数えないらしい.
time_t
型を用いて扱うことが可能.
#include <iostream> #include <ctime> int main () { // int64_t unixtime_i = 1651736619; // 2022-05-05 16:43:39 // time_t now = (time_t)unixttime_t; time_t now = std::time(nullptr); // 現在時刻 tm *tm_event = localtime(&unixtime); // 現地時間に直す int year = tm_event->tm_year + 1900; // tm_year は 1900 年始まり int month = tm_event->tm_mon + 1; // tm_mon は 0 始まり int day = tm_event->tm_mday; std::exit(0); }
tm
は以下のような定義