LoginSignup
0
1

More than 1 year has passed since last update.

[Python][Tips] さくっと現在日時を取得したい場合

Last updated at Posted at 2022-09-27

さくっと現在日時を取得したい時に便利なTips。
大量のデータを扱う場合、現在日時をファイル名先頭に付与することで新旧でソーティングできるのでよく利用しています。

import datetime

now = datetime.datetime.now() # 現在日時を取得
dt = now.strftime('%Y%m%d%H%M%S') # YYYYMMDDhhmmssの書式に整形
print(dt) #20220927221536
0
1
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
1