<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Zoneinfo on 每日拍拍</title>
    <link>https://dailypypy.org/tags/zoneinfo/</link>
    <description>Recent content in Zoneinfo on 每日拍拍</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>zh-tw</language>
    <copyright>© 2026 每日拍拍</copyright>
    <lastBuildDate>Fri, 15 May 2026 12:12:00 +0800</lastBuildDate><atom:link href="https://dailypypy.org/tags/zoneinfo/index.xml" rel="self" type="application/rss+xml" />
    <follow_challenge>
      <feedId>155076163427069952</feedId>
      <userId>154825760438254592</userId>
    </follow_challenge>
    
    
    <item>
      <title>Python zoneinfo 實戰：時區、DST 與排程時間處理完全攻略</title>
      <link>https://dailypypy.org/learn/python-zoneinfo/</link>
      <pubDate>Fri, 15 May 2026 12:12:00 +0800</pubDate>
      
      <guid>https://dailypypy.org/learn/python-zoneinfo/</guid>
      <description>&lt;!---
1440x768
prompt: masterpiece, best quality, highres, clean anime illustration, japanese anime style, soft shading, flat color design, 1girl, black hair, green eyes, white off-shoulder shirt, black short skirt, from above, leaning forward, curious bright smile, looking at viewer, pale coral background, subtle floating clocks and globe shapes without text, neat composition, detailed eyes, cute and smart vibe, minimal background, polished illustration, no text
negative prompt: worst quality, bad eye, bad hand, extra limbs, manga, multiple views, monochrome, text, signature
---&gt;

&lt;h2 class=&#34;relative group&#34;&gt;一. 前言：時間看起來簡單，直到它跨過時區 
    &lt;div id=&#34;一-前言時間看起來簡單直到它跨過時區&#34; class=&#34;anchor&#34;&gt;&lt;/div&gt;
    
    &lt;span
        class=&#34;absolute top-0 w-6 transition-opacity opacity-0 ltr:-left-6 rtl:-right-6 not-prose group-hover:opacity-100&#34;&gt;
        &lt;a class=&#34;group-hover:text-primary-300 dark:group-hover:text-neutral-700&#34;
            style=&#34;text-decoration-line: none !important;&#34; href=&#34;#%e4%b8%80-%e5%89%8d%e8%a8%80%e6%99%82%e9%96%93%e7%9c%8b%e8%b5%b7%e4%be%86%e7%b0%a1%e5%96%ae%e7%9b%b4%e5%88%b0%e5%ae%83%e8%b7%a8%e9%81%8e%e6%99%82%e5%8d%80&#34; aria-label=&#34;定位點&#34;&gt;#&lt;/a&gt;
    &lt;/span&gt;        
    
&lt;/h2&gt;
&lt;p&gt;寫程式處理時間，很容易一開始覺得沒什麼。&lt;code&gt;datetime.now()&lt;/code&gt; 一叫，資料庫一存，畫面一顯示，事情好像就結束了。
然後某天使用者在紐約，伺服器在東京，資料庫存 UTC，排程又遇到夏令時間。拍拍君通常會在這種時候默默放下咖啡。
因為問題不是「怎麼取得現在時間」，而是這個時間到底屬於哪個時區、是不是 UTC、要顯示給誰看、遇到 DST 時凌晨兩點到底存在不存在。
Python 3.9 開始內建 &lt;code&gt;zoneinfo&lt;/code&gt;，讓我們不用額外安裝 &lt;code&gt;pytz&lt;/code&gt;，就能使用 IANA time zone database，例如 &lt;code&gt;Asia/Taipei&lt;/code&gt;、&lt;code&gt;America/New_York&lt;/code&gt;、&lt;code&gt;Europe/London&lt;/code&gt;。
今天這篇會很務實地處理幾個場景：&lt;/p&gt;</description>
      
    </item>
    
  </channel>
</rss>
