[問題] 美國伺服器時區

看板Python作者 (gigigigi)時間6年前 (2018/10/26 22:11), 編輯推噓5(503)
留言8則, 4人參與, 6年前最新討論串1/1
因為我台灣文章, 我會找最近20分鐘裡面文章 那我用下面程式碼取得目前時間 - 台灣文章的發文時間 moment.utc(time.asctime(time.localtime(time.time()))) 但是美國伺服器跟台灣相差16小時 , 我現在是 hard code 扣掉 960分鐘 請問有辦法讓程式碼寫靈活點 設定成 +8 時區嘛? 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 175.182.113.232 ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1540563088.A.263.html

10/26 22:24, 6年前 , 1F
內建就有datetime可以用又能設定timezone不用嗎?
10/26 22:24, 1F

10/26 22:27, 6年前 , 2F
好我研究看看~感謝喔
10/26 22:27, 2F

10/27 09:03, 6年前 , 3F
moment.utc('your time').timezone('US/Pacific')
10/27 09:03, 3F

10/27 09:08, 6年前 , 4F
東部是US/Eastern ref: https://goo.gl/AHiCJq
10/27 09:08, 4F

10/27 10:53, 6年前 , 5F
前兩篇才問過時區轉換 上網查一定能自己解答這問題啊....
10/27 10:53, 5F

10/27 10:57, 6年前 , 6F
將問題拆成關鍵字餵google 搜尋答案的能力也是會累積的
10/27 10:57, 6F

10/27 11:06, 6年前 , 7F
"python timezone convert" -> https://goo.gl/5Psrfz
10/27 11:06, 7F

10/27 11:08, 6年前 , 8F
"python moment timezone convert" -> rexy大貼的moment
10/27 11:08, 8F
文章代碼(AID): #1Rqo2G9Z (Python)
文章代碼(AID): #1Rqo2G9Z (Python)