<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
    <channel>
        <title>Datetimeoffset - Tag - 程式狂想筆記</title>
        <link>https://malagege.github.io/blog/tags/datetimeoffset/</link>
        <description>Datetimeoffset - Tag - 程式狂想筆記</description>
        <generator>Hugo -- gohugo.io</generator><language>zh-tw</language><lastBuildDate>Tue, 28 Apr 2026 15:33:57 &#43;0800</lastBuildDate><atom:link href="https://malagege.github.io/blog/tags/datetimeoffset/" rel="self" type="application/rss+xml" /><item>
    <title>DateTime.Parse 解析文字時間時區會遺失問題</title>
    <link>https://malagege.github.io/blog/posts/datetime-parse-loses-timezone-info/</link>
    <pubDate>Tue, 28 Apr 2026 15:33:57 &#43;0800</pubDate>
    <author>malagege</author>
    <guid>https://malagege.github.io/blog/posts/datetime-parse-loses-timezone-info/</guid>
    <description><![CDATA[<p>最近接到一個專案，原本時間欄位大多使用 <code>DateTime</code>，但因為要串另外一套 API，對方是使用 <code>DateTimeOffset</code>。我原本以為只要 JSON 裡面有時間字串，應該就會連時區一起帶著走，結果實際追問題時，還真的踩到時間少了 8 小時的坑。</p>
<p>後來往下追，問題點其實就卡在 <code>DateTime.Parse</code> 這種「把字串重新轉回時間」的流程。尤其當字串裡本來就沒有時區資訊時，這一步很容易把原本上下文中的時區概念弄丟。</p>]]></description>
</item>
</channel>
</rss>
