Skip to content

Instantly share code, notes, and snippets.

@aflc
Created May 17, 2013 13:02
Show Gist options
  • Save aflc/5598885 to your computer and use it in GitHub Desktop.
Save aflc/5598885 to your computer and use it in GitHub Desktop.
UTCからローカル時間へのお手軽な変換 ref: http://qiita.com/items/5fcee53316fe49b6c550
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