[python] timestamp를 datetime으로 변환하기

cateto·2021년 7월 22일
0
post-thumbnail
import datetime

"""
@author : cateto
@param : timestamp
@return : datetime (format to yyyymmdd)
"""
def timestamp_to_yyyymmdd(tempstamp):
    tempstamp = int(tempstamp)
    temp = datetime.datetime.fromtimestamp(tempstamp)
    return temp.strftime("%Y%m%d")

print(timestamp_to_yyyymmdd(1623596370))

strftime("%Y%m%d") 를 사용해서 dateformatting도 가능하다.

다양한 format은 다음 링크를 참고

W3Schools Python Date

profile
Curious for Everything

0개의 댓글