欲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雖然