Skip to content

Instantly share code, notes, and snippets.

@Tukki
Created October 25, 2012 17:02
Show Gist options
  • Save Tukki/3954052 to your computer and use it in GitHub Desktop.
Save Tukki/3954052 to your computer and use it in GitHub Desktop.
获取昨天的某个时刻
import datetime
yestoday = datetime.date.today() - datetime.timedelta(days=1)
print yestoday
yestoday_datetime = datetime.datetime.combine(yestoday, datetime.time.min)
print yestoday_datetime
yestoday_datetime = datetime.datetime.combine(yestoday, datetime.time())
print yestoday_datetime
the_time = yestoday_datetime + datetime.timedalta(hours=6)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment