获取当前时间
>>> now = arrow.utcnow()
>>> print(now)
2016-07-12T03:56:23.917000+00:00
时间增减
>>> one_hour_ago = now.replace(hours = -1)
>>> print(one_hour_ago)
2016-07-12T02:56:23.917000+00:00
>>> one_day_ago = now.replace(days = -1)
>>> print(one_day_ago)
2016-07-11T03:56:23.917000+00:00
>>> minutes_ago = now.replace(minutes = 20)
>>> print(minutes_ago)
2016-07-12T04:16:23.917000+00:00
时区修改
>>> now_local = now.to('Asia/Shanghai')
>>> print now_local
2016-07-12T11:56:23.917000+08:00
字符串转时间
>>> arrow.get(' 2014-12-12T00:00:00.000+0800')
<Arrow [2014-12-12T00:00:00+08:00]>
>>> arrow.get(' 2014-12-12T00:00:00.000+0800').format()
u'2014-12-12 00:00:00+08:00'
时间戳
>>> now_local.timestamp
1468295783
格式化
>>> now_local.format("YYYYMMDD")
u'20160712'
>>> now_local.format("YYYYMMDDHHmmss")
u'20160712115623'
>>> now_local.format("YYYY/MM/DD")
u'2016/07/12'
本地化个性时间短语
>>> now_local.humanize()
u'13 minutes ago'
>>> now_local.humanize(locale='zh')
u'14\u5206\u949f\u524d'
本地化支持列表
传送门