Quick Note
將字串轉為 datetime 型態(string to datetime)
import time, datetime
timestring = "2005-09-01 12:30:09"
time_format = "%Y-%m-%d %H:%M:%S"
datetime.datetime.fromtimestamp(time.mktime(time.strptime(timestring, time_format)))
取得 datetime 的 UNIX timestamp (from 1970)
import time, datetime
# eq : now = int(time.time())
now = int(datetime.datetime.now().strftime("%s"))
沒有留言:
張貼留言