ccwang002 / ccwang002.github.io

My personal blog
https://blog.liang2.tw
MIT License
3 stars 5 forks source link

posts/2015/09/datetime-sqlite/ #9

Open utterances-bot opened 8 months ago

utterances-bot commented 8 months ago

Datetime in SQLite and Python

整理在 Python 中處理時區的問題,並如何自 SQLite 存取考慮時區的時間

https://blog.liang2.tw/posts/2015/09/datetime-sqlite/

arguskao commented 8 months ago

整篇看完,還是有點不太懂,我用python3.9 + Sqlite3 是不是還是不能用.strftime(%H:%M:%S %Y-%m-%d)? 都只能存2015-09-29 12:48:16.671538 這樣

ccwang002 commented 8 months ago

你可以採用非預設的時間格式,把它當成一般字串存取即可,然後自己處理字串、Python datetime 之間的轉換。