LoginSignup
0
0

More than 1 year has passed since last update.

#python で JST(日本時間)などの現地時刻で今日の始まりの unixtimstamp を得る例

Last updated at Posted at 2019-04-02
from datetime import datetime
import pytz, time

tz = pytz.timezone('Asia/Tokyo')

d = datetime.now(tz=tz).replace(hour=0, minute=0, second=0, microsecond=0)
print(d)

unixtimestamp = time.mktime(d.timetuple())

print(unixtimestamp)

e.g

$ python3 today.py
2019-04-02 00:00:00+09:00
1554130800.0

ツールで逆変換して正しいかどうか確認してみる

Unixtime相互変換ツール - konisimple tools

image

Original by Github issue

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

Twitter

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