Created
May 17, 2013 13:02
-
-
Save aflc/5598885 to your computer and use it in GitHub Desktop.
UTCからローカル時間へのお手軽な変換 ref: http://qiita.com/items/5fcee53316fe49b6c550
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
import calendar | |
import time | |
# utctime -> localtime | |
utcnow = datetime.datetime.utcnow() | |
local = datetime.datetime.fromtimestamp(calendar.timegm(utcnow.timetuple())) | |
# localtime -> utctime | |
localnow = datetime.datetime.now() | |
utc = datetime.datetime.urcfromtimestamp(time.mktime(localnow.timetuple())) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment