欲datetime.datetime(2016, 11, 21, 5, 34, 38, 826339, tzinfo=<UTC>)
作为Nov. 21, 2016, 11:04 a.m.
变化DateTime对象到字符串
的时间转换中的日期时间对象处于UST但我希望它被转换成IST(UST + 05:30)。
我尝试使用的strftime为:
>>> datetime(2016, 11, 21, 5, 34, 38, 826339, tzinfo=<UTC>).isoformat(' ')
File "<stdin>", line 1
datetime(2016, 11, 21, 5, 34, 38, 826339, tzinfo=<UTC>).isoformat(' ')
^
SyntaxError: invalid syntax
我能得到一些帮助在这里。
PS:我使用python
编辑:
cr_date = datetime(2016, 11, 21, 5, 34, 38, 826339) #excluding the timezone
我可以得到想要的部分reults:
cr_date.strftime('%b. %d, %Y %H:%M')
'Oct. 31, 2013 18:23
没有得到AM/PM虽然