Skip to content

Instantly share code, notes, and snippets.

@shau-lok
Last active October 30, 2016 14:09
Show Gist options
  • Save shau-lok/fe5b8d6826c9a7644634ba38fc7de7bf to your computer and use it in GitHub Desktop.
Save shau-lok/fe5b8d6826c9a7644634ba38fc7de7bf to your computer and use it in GitHub Desktop.
时间处理
# 2016-10-30T14:02:48.269Z
from datetime import datetime, timedelta
def generate_timestamp(self):
# now = arrow.now()
# now.to('GMT')
# now.format("YYYY-MM-dd'T'HH:mm:ss.SSSZZ")
date_format = "%Y-%m-%dT%H:%M:%S.%f"
now = datetime.utcnow().strftime(date_format)
now = str(now)[0:-3]
return now + "Z"
# change 2016-09-19 to 09/19/2016
import arrow
arrow.get('2016-09-09', 'YYYY-MM-DD').format('MM/DD/YYYY')
# library:
#
# datetime [https://docs.python.org/2/library/datetime.html]
# arrow [http://arrow.readthedocs.io/en/latest/]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment