0
0

More than 3 years have passed since last update.

Python3でUTC(整数秒)

Posted at

Python3で現在時刻のUTC秒を取得する方法を探そうとしたら、あまりそのものズバリじゃない、情報が盛りだくさんのが多いなぁ、と思ったので。

  • ズバリのプログラム
import time

x = int(time.time())
print(x)
  • 実行結果
1598166633
% date -r 1598166633 
2020年 8月23日 日曜日 16時10分33秒 JST
  • 長いプログラム
import time

utc_float = time.time()
print("utc_float: " + str(utc_float) + " " + str(type(utc_float)))
utc_int = int(time.time())
print("utc_int: " + str(utc_int) + " " + str(type(utc_int)))
  • 実行結果
utc_float: 1598167452.5028915 <class 'float'>
utc_int: 1598167452 <class 'int'>
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0