Conversion between unixtime and datetime

datetime -> unixtime

import time
time.mktime(datetime_obj.timetuple())

unixtime -> datetime

import datetime
datetime.datetime.fromtimestamp(unixtime)

so. I'll forget it, so make a note

Recommended Posts

Conversion between unixtime and datetime
python unix-time <-> datetime conversion
Conversion between singular and plural of words
Mutual conversion between Qiita articles and Jupyter notebook
Relationship between Firestore and Go data type conversion
Conversion between Julian day and Gregorian calendar date
[Python] Conversion memo between time data and numerical data
Mutual conversion between fixed point and binary numbers
Between parametric and nonparametric
Hexadecimal string and string conversion
Mutual conversion between date and days elapsed from January 1, 2000
Mutual conversion between JSON and YAML / TOML in Python
datetime and file write and backup
Correspondence between pandas and SQL
Difference between "categorical_crossentropy" and "sparse_categorical_crossentropy"
Difference between regression and classification
I made a class that easily performs unixtime ← → datetime conversion
Collaboration between PTVS and Anaconda
Connection between flask and sqlite3
About Python datetime and timezone
Difference between np.array and np.arange
Difference between MicroPython and CPython
Cooperation between py2exe and setuptools
Boundary between C and Golang
Difference between ps a and ps -a
Difference between return and print-Python
Differences between Windows and Linux directories
Django's MVT-Relationship between Models and Modules-
Difference between java and python (memo)
Difference between list () and [] in Python
Differences between yum commands and APT commands
Difference between SQLAlchemy filter () and filter_by ()
Difference between == and is in python
[Note] Conflict between matplotlib and zstd
Differences between symbolic links and hard links
Memorandum (difference between csv.reader and csv.dictreader)
Correspondence between RecyclerView and Marker (Kotlin)
(Note) Difference between gateway and default gateway
Cooperation between python module and API
Difference between Numpy randint and Random randint
Differences between Python, stftime and strptime
Difference between sort and sorted (memorial)
Difference between python2 series and python3 series dict.keys ()
Speed comparison between CPython and PyPy
[Python] Difference between function and method
Difference between SQLAlchemy flush () and commit ()
Python --Difference between exec and eval
[Python] Difference between randrange () and randint ()
[Python] Difference between sorted and sorted (Colaboratory)
[Python] Summary of conversion between character strings and numerical values (ascii code)