添加链接
注册
登录
link管理
链接快照平台
输入网页链接,自动生成快照
标签化管理网页链接
相关文章推荐
发财的黄花菜
·
Django ForeignKey ...
·
1 月前
·
温暖的酱牛肉
·
mysql-tutorial/article ...
·
6 月前
·
爱玩的小笼包
·
IF THEN Statement in ...
·
8 月前
·
幸福的书签
·
杭州八所重高差距有多大? - 知乎
·
9 月前
·
热心肠的莲藕
·
查询和响应ECS系统事件 - 云服务器 ...
·
1 年前
·
link管理
›
Why Use DateTimeOffset | Blog
https://ardalis.com/why-use-datetimeoffset/
路过的泡面
6 月前
</noscript><div id="___gatsby"><div style="outline:none" tabindex="-1" id="gatsby-focus-wrapper"><div><nav class="navbar is-transparent" role="navigation" aria-label="main-navigation"><div class="container"><div class="navbar-brand"><a class="navbar-item" title="Logo" href="/"><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASwAAAA8CAYAAADc3IdaAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAB3RJTUUH5AUaFDE304pirgAAFAJJREFUeNrtnWuUFNW1x/+8RBQRb0TUCCKaiIrgMFXVNeioGDVqjBFRQ2JMYu7FBwJdp7pnesY7gBo16sVHjBo0PtY1JgZ0KcShq6p73g+J4AMf+MAkeNVEE18gIjjAOvdD74Geoaf7nO6q7p6e+rDX4gN9XlX1m3P22fu/wTlHvkydFz1AYfYNqhm/UzHsJZlMZfYdGost0eY5E/I5Tt+yNwCHA7hS0L7rr5lvUu9XPjtTDGvByQvXcr22k+s17QLWwU9e/BJXmbXUf1j9BlhnA+CC1jyA1+lIAHcD+A2Ae9LYfQDOk2h3OICfAfgDgLUAXgLQDuAuAKf6wBK0sjkrRyhG9I1AdQtXmS1sWriRq2bsU8WoP8oHQr/4EGdIAGvFAF6n6RLrdLtgm98G0JamnR0Ern19YGWwcub8Qo+0c9V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FWHRDcmVhdGlvbiB0aW1lADX3DwkAAAAldEVYdGRhdGU6Y3JlYXRlADIwMjAtMDUtMjZUMjA6Mzk6NTMrMDA6MDBIKo/0AAAAJXRFWHRkYXRlOm1vZGlmeQAyMDIwLTA1LTI2VDIwOjM5OjUzKzAwOjAwOXc3SAAAAAx0RVh0RGVzY3JpcHRpb24AEwkhIwAAAAt0RVh0RGlzY2xhaW1lcgC3wLSPAAAACXRFWHRTb2Z0d2FyZQBdcP86AAAAB3RFWHRTb3VyY2UA9f+D6wAAAAZ0RVh0VGl0bGUAqO7SJwAAAAh0RVh0V2FybmluZwDAG+aHAAAAAElFTkSuQmCC" alt="Ardalis" style="width:150px"/></a><div class="navbar-burger burger " data-target="navMenu" role="button" tabindex="0"><span/><span/><span/></div></div><div id="navMenu" class="navbar-menu "><div class="navbar-start has-text-centered"><a class="navbar-item" href="/blog">Blog</a><a class="navbar-item" href="/training-classes">Training</a><a class="navbar-item" href="/mentoring">Mentoring</a><a class="navbar-item" href="/tips">Subscribe</a><a class="navbar-item" href="/interviews">Interviews</a><a class="navbar-item" href="/books">Books</a><a class="navbar-item" href="/tools-used">Tools Used</a><a class="navbar-item" href="/contact-us">Contact</a></div><div class="navbar-end has-text-centered"><a class="navbar-item" href="https://www.facebook.com/StevenAndrewSmith" target="_blank" rel="noopener noreferrer"><span class="icon"><img src="data:image/svg+xml;base64,PHN2ZyByb2xlPSJpbWciIHZpZXdCb3g9IjAgMCAyNCAyNCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48dGl0bGU+RmFjZWJvb2sgaWNvbjwvdGl0bGU+PHBhdGggZD0iTTIyLjY3NiAwSDEuMzI0Qy41OTMgMCAwIC41OTMgMCAxLjMyNHYyMS4zNTJDMCAyMy40MDguNTkzIDI0IDEuMzI0IDI0aDExLjQ5NHYtOS4yOTRIOS42ODl2LTMuNjIxaDMuMTI5VjguNDFjMC0zLjA5OSAxLjg5NC00Ljc4NSA0LjY1OS00Ljc4NSAxLjMyNSAwIDIuNDY0LjA5NyAyLjc5Ni4xNDF2My4yNGgtMS45MjFjLTEuNSAwLTEuNzkyLjcyMS0xLjc5MiAxLjc3MXYyLjMxMWgzLjU4NGwtLjQ2NSAzLjYzSDE2LjU2VjI0aDYuMTE1Yy43MzMgMCAxLjMyNS0uNTkyIDEuMzI1LTEuMzI0VjEuMzI0QzI0IC41OTMgMjMuNDA4IDAgMjIuNjc2IDAiLz48L3N2Zz4=" alt="facebook"/></span></a><a class="navbar-item" href="https://www.linkedin.com/in/stevenandrewsmith" target="_blank" rel="noopener noreferrer"><span class="icon"><img src="data:image/svg+xml;base64,PHN2ZyByb2xlPSJpbWciIHZpZXdCb3g9IjAgMCAyNCAyNCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48dGl0bGU+TGlua2VkSW4gaWNvbjwvdGl0bGU+PHBhdGggZD0iTTIwLjQ0NyAyMC40NTJoLTMuNTU0di01LjU2OWMwLTEuMzI4LS4wMjctMy4wMzctMS44NTItMy4wMzctMS44NTMgMC0yLjEzNiAxLjQ0NS0yLjEzNiAyLjkzOXY1LjY2N0g5LjM1MVY5aDMuNDE0djEuNTYxaC4wNDZjLjQ3Ny0uOSAxLjYzNy0xLjg1IDMuMzctMS44NSAzLjYwMSAwIDQuMjY3IDIuMzcgNC4yNjcgNS40NTV2Ni4yODZ6TTUuMzM3IDcuNDMzYy0xLjE0NCAwLTIuMDYzLS45MjYtMi4wNjMtMi4wNjUgMC0xLjEzOC45Mi0yLjA2MyAyLjA2My0yLjA2MyAxLjE0IDAgMi4wNjQuOTI1IDIuMDY0IDIuMDYzIDAgMS4xMzktLjkyNSAyLjA2NS0yLjA2NCAyLjA2NXptMS43ODIgMTMuMDE5SDMuNTU1VjloMy41NjR2MTEuNDUyek0yMi4yMjUgMEgxLjc3MUMuNzkyIDAgMCAuNzc0IDAgMS43Mjl2MjAuNTQyQzAgMjMuMjI3Ljc5MiAyNCAxLjc3MSAyNGgyMC40NTFDMjMuMiAyNCAyNCAyMy4yMjcgMjQgMjIuMjcxVjEuNzI5QzI0IC43NzQgMjMuMiAwIDIyLjIyMiAwaC4wMDN6Ii8+PC9zdmc+" alt="linkedin"/></span></a><a class="navbar-item" href="https://twitter.com/ardalis" target="_blank" rel="noopener noreferrer"><span class="icon"><img src="data:image/svg+xml;base64,PHN2ZyByb2xlPSJpbWciIHZpZXdCb3g9IjAgMCAyNCAyNCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48dGl0bGU+VHdpdHRlciBpY29uPC90aXRsZT48cGF0aCBkPSJNMjMuOTU0IDQuNTY5Yy0uODg1LjM4OS0xLjgzLjY1NC0yLjgyNS43NzUgMS4wMTQtLjYxMSAxLjc5NC0xLjU3NCAyLjE2My0yLjcyMy0uOTUxLjU1NS0yLjAwNS45NTktMy4xMjcgMS4xODQtLjg5Ni0uOTU5LTIuMTczLTEuNTU5LTMuNTkxLTEuNTU5LTIuNzE3IDAtNC45MiAyLjIwMy00LjkyIDQuOTE3IDAgLjM5LjA0NS43NjUuMTI3IDEuMTI0QzcuNjkxIDguMDk0IDQuMDY2IDYuMTMgMS42NCAzLjE2MWMtLjQyNy43MjItLjY2NiAxLjU2MS0uNjY2IDIuNDc1IDAgMS43MS44NyAzLjIxMyAyLjE4OCA0LjA5Ni0uODA3LS4wMjYtMS41NjYtLjI0OC0yLjIyOC0uNjE2di4wNjFjMCAyLjM4NSAxLjY5MyA0LjM3NCAzLjk0NiA0LjgyNy0uNDEzLjExMS0uODQ5LjE3MS0xLjI5Ni4xNzEtLjMxNCAwLS42MTUtLjAzLS45MTYtLjA4Ni42MzEgMS45NTMgMi40NDUgMy4zNzcgNC42MDQgMy40MTctMS42OCAxLjMxOS0zLjgwOSAyLjEwNS02LjEwMiAyLjEwNS0uMzkgMC0uNzc5LS4wMjMtMS4xNy0uMDY3IDIuMTg5IDEuMzk0IDQuNzY4IDIuMjA5IDcuNTU3IDIuMjA5IDkuMDU0IDAgMTMuOTk5LTcuNDk2IDEzLjk5OS0xMy45ODYgMC0uMjA5IDAtLjQyLS4wMTUtLjYzLjk2MS0uNjg5IDEuOC0xLjU2IDIuNDYtMi41NDhsLS4wNDctLjAyeiIvPjwvc3ZnPg==" alt="twitter"/></span></a><a class="navbar-item" href="https://www.youtube.com/ardalis/" target="_blank" rel="noopener noreferrer"><span class="icon"><img src="data:image/svg+xml;base64,PHN2ZyByb2xlPSJpbWciIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDI0IDI0Ij48dGl0bGU+WW91VHViZSBpY29uPC90aXRsZT48cGF0aCBkPSJNMjMuNDk1IDYuMjA1YTMuMDA3IDMuMDA3IDAgMCAwLTIuMDg4LTIuMDg4Yy0xLjg3LS41MDEtOS4zOTYtLjUwMS05LjM5Ni0uNTAxcy03LjUwNy0uMDEtOS4zOTYuNTAxQTMuMDA3IDMuMDA3IDAgMCAwIC41MjcgNi4yMDVhMzEuMjQ3IDMxLjI0NyAwIDAgMC0uNTIyIDUuODA1IDMxLjI0NyAzMS4yNDcgMCAwIDAgLjUyMiA1Ljc4MyAzLjAwNyAzLjAwNyAwIDAgMCAyLjA4OCAyLjA4OGMxLjg2OC41MDIgOS4zOTYuNTAyIDkuMzk2LjUwMnM3LjUwNiAwIDkuMzk2LS41MDJhMy4wMDcgMy4wMDcgMCAwIDAgMi4wODgtMi4wODggMzEuMjQ3IDMxLjI0NyAwIDAgMCAuNS01Ljc4MyAzMS4yNDcgMzEuMjQ3IDAgMCAwLS41LTUuODA1ek05LjYwOSAxNS42MDFWOC40MDhsNi4yNjQgMy42MDJ6Ii8+PC9zdmc+" alt="youtube"/></span></a><a class="navbar-item" href="https://github.com/ardalis" target="_blank" rel="noopener noreferrer"><span class="icon"><img src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rP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zIsMTE0LjU3M3oiLz48L2c+PGRpdiBpZD0iZGl2U2NyaXB0c1VzZWQiIHN0eWxlPSJkaXNwbGF5Om5vbmUiLz48c2NyaXB0IGlkPSJnbG9iYWxWYXJzRGV0ZWN0aW9uIiBzcmM9ImNocm9tZS1leHRlbnNpb246Ly9jbWtkYm1mbmRrZmdlYmxkaG5rYmZobG5lZWZkYWFpcC9qcy93cnNfZW52LmpzIi8+PC9zdmc+" alt="Github"/></span></a></div></div></div></nav><div><section class="section"><div class="full-width-image-container margin-top-0" style="background-image:url(/static/blogging-ea4fdaec566aafddd0291352e3f8802d.jpg)"/><div class="tile is-ancestor"><div class="tile is-vertical is-7"><div class="tile"><div class="tile is-parent"><article class="tile is-child box"><div class="container content"><div class="columns"><div class="column is-10 is-offset-1"><h1 class="title is-size-2 has-text-weight-bold is-bold-light">Why Use DateTimeOffset</h1><p style="width:100%;font-weight:bold;color:#3571B8"> Date Published: <!-- -->17 January 2022</p><p><img src="/static/c8166182a364652dc4e8116239397bcd/4e530/why-use-datetimeoffset.png" alt="Why Use DateTimeOffset" width="100%"/></p><div><p>Raise your hand if you've stored entity values in a database as DateTime.</p> <p>Ok, everybody has their hand up. You can put your hand down - you look silly doing that while reading an article on some website.</p> <p>Using DateTime for entity properties and database fields is ubiquitous, but if you really care about the time portion of the value, it's often ambiguous. What time zone is the date in? Is it stored as UTC? From everywhere that touches it? How can you be sure? DateTimeOffset provides a solution to this problem.</p> <h2>Storing DateTime Values</h2> <p>The simple DateTime type (<a href="https://ardalis.com/datetime-as-a-value-object/">which makes a great example of a Value Object</a>), always assumes the local machine's relative time. When you ask it for <code class="language-text">.Today</code> or <code class="language-text">.Now</code> it uses the local system clock. This can easily cause problems between machines with different times and/or timezones. It can be helpful to look at the output of a particular DateTime value as a string.</p> <div class="gatsby-highlight" data-language="csharp"><pre class="language-csharp"><code class="language-csharp"><span class="token class-name"><span class="token keyword">var</span></span> rightNow <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token constructor-invocation class-name">DateTime</span><span class="token punctuation">(</span><span class="token number">2022</span><span class="token punctuation">,</span><span class="token number">1</span><span class="token punctuation">,</span><span class="token number">17</span><span class="token punctuation">,</span><span class="token number">18</span><span class="token punctuation">,</span><span class="token number">11</span><span class="token punctuation">,</span><span class="token number">30</span><span class="token punctuation">)</span><span class="token punctuation">;</span> Console<span class="token punctuation">.</span><span class="token function">WriteLine</span><span class="token punctuation">(</span>rightNow<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// 1/17/2022 6:11:30 PM</span> Console<span class="token punctuation">.</span><span class="token function">WriteLine</span><span class="token punctuation">(</span>rightNow<span class="token punctuation">.</span><span class="token function">ToLocalTime</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// 1/17/2022 1:11:30 PM</span> Console<span class="token punctuation">.</span><span class="token function">WriteLine</span><span class="token punctuation">(</span>rightNow<span class="token punctuation">.</span><span class="token function">ToUniversalTime</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// 1/17/2022 11:11:30 PM</span> Console<span class="token punctuation">.</span><span class="token function">WriteLine</span><span class="token punctuation">(</span>rightNow<span class="token punctuation">.</span><span class="token function">ToString</span><span class="token punctuation">(</span><span class="token string">"yyyy-MM-ddTHH:mm:ss"</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// 2022-01-17T18:11:30</span></code></pre></div> <p>The initial time is 6:11pm on 17 Jan 2022 on my computer here in Ohio, which is Eastern Standard Time (UTC-5). The <code class="language-text">rightNow</code> variable doesn't include any time zone data in it. The <code class="language-text">DateTime</code> functions <code class="language-text">ToLocalTime</code> and <code class="language-text">ToUniversalTime</code> assume that the data they're operating is in UTC or local time, respectively. As a result, of the four different times shown, the one produced by <code class="language-text">ToLocalTime</code> is incorrect, since it's subtracting 5 hours from the actual time of 6:11pm.</p> <p>Note that when you store datetimes in your application, they'll be stored based on whatever machine timezone they're running on, unless you're extremely disciplined about using UTC times wherever you modify the dates. And even if you are, there's no way to look at your data and see that you were, after the fact. The data simply won't know.</p> <p>What happens when the same code is run on different developers' machines in different timezones? What happens when tests are run in this case?</p> <p>What happens when you move your cloud-hosted app from one region to another? What happens if the app spans region in production for high-availability (HA) reasons?</p> <p>For all of these reasons, it can be worthwhile to store dates in your application using the DateTimeOffset type.</p> <h2>DateTimeOffset</h2> <p>DateTimeOffset is both a .NET type and a SQL Server type (other databases have equivalents, too). The main difference between it and the simpler DateTime type we all know and love is that it includes a time zone offset from UTC. Thus, it's always clear when looking at a DateTimeOffset what time is meant, whether UTC or local.</p> <p>It is always clear what actual time is depicted by DateTimeOffset, whether it's UTC or local.</p> <p>Adding to the example above, it can be helpful to see what DateTimeOffset values look like when represented as strings:</p> <div class="gatsby-highlight" data-language="csharp"><pre class="language-csharp"><code class="language-csharp"><span class="token class-name">DateTimeOffset</span> rightNowHere <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token constructor-invocation class-name">DateTimeOffset</span><span class="token punctuation">(</span>rightNow<span class="token punctuation">)</span><span class="token punctuation">;</span> Console<span class="token punctuation">.</span><span class="token function">WriteLine</span><span class="token punctuation">(</span>rightNowHere<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// 1/17/2022 6:11:30 PM -05:00</span> Console<span class="token punctuation">.</span><span class="token function">WriteLine</span><span class="token punctuation">(</span>rightNowHere<span class="token punctuation">.</span><span class="token function">ToLocalTime</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// 1/17/2022 6:11:30 PM -05:00</span> Console<span class="token punctuation">.</span><span class="token function">WriteLine</span><span class="token punctuation">(</span>rightNowHere<span class="token punctuation">.</span><span class="token function">ToUniversalTime</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// 1/17/2022 11:11:30 PM +00:00</span> Console<span class="token punctuation">.</span><span class="token function">WriteLine</span><span class="token punctuation">(</span>rightNowHere<span class="token punctuation">.</span><span class="token function">ToString</span><span class="token punctuation">(</span><span class="token string">"yyyy-MM-ddTHH:mm:ss"</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// 2022-01-17T18:11:30</span></code></pre></div> <p>Two things to note in the listing above: the ToLocalTime value is correct and the standard ToString values all include the timezone offset (-05:00 when local, +00:00 when UTC). The last value's format string doesn't include the offset, which is represented in the format string as taking a nap: <code class="language-text">zzz</code>.</p> <div class="gatsby-highlight" data-language="csharp"><pre class="language-csharp"><code class="language-csharp">Console<span class="token punctuation">.</span><span class="token function">WriteLine</span><span class="token punctuation">(</span>rightNowHere<span class="token punctuation">.</span><span class="token function">ToString</span><span class="token punctuation">(</span><span class="token string">"yyyy'-'MM'-'dd'T'HH':'mm':'ss zzz"</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// 2022-01-17T18:11:30 -05:00</span></code></pre></div> <h2>DateTimeOffset in SQL Server</h2> <p>SQL Server supports both DateTime and DateTimeOffset values. DateTimeOffset uses variable precision and so <em>can</em> take up more space than DateTime, but doesn't <em>always</em> do so. <a href="https://database.guide/datetime-vs-datetimeoffset-in-sql-server-whats-the-difference/">Compare DateTimeOffset and DateTime on SQL Server</a> and choose which one makes sense for your needs. If you just want to quickly see the difference, run these queries:</p> <div class="gatsby-highlight" data-language="sql"><pre class="language-sql"><code class="language-sql"><span class="token keyword">select</span> GetDate<span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token keyword">select</span> SYSDATETIME<span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token keyword">select</span> SYSDATETIMEOFFSET<span class="token punctuation">(</span><span class="token punctuation">)</span></code></pre></div> <p>Results (note precision difference in second and third result):</p> <div class="gatsby-highlight" data-language="sql"><pre class="language-sql"><code class="language-sql"><span class="token number">2022</span><span class="token operator">-</span><span class="token number">01</span><span class="token operator">-</span><span class="token number">17</span> <span class="token number">18</span>:<span class="token number">30</span>:<span class="token number">18.227</span> <span class="token number">2022</span><span class="token operator">-</span><span class="token number">01</span><span class="token operator">-</span><span class="token number">17</span> <span class="token number">18</span>:<span class="token number">30</span>:<span class="token number">18.2292271</span> <span class="token number">2022</span><span class="token operator">-</span><span class="token number">01</span><span class="token operator">-</span><span class="token number">17</span> <span class="token number">18</span>:<span class="token number">30</span>:<span class="token number">18.2292271</span> <span class="token operator">-</span><span class="token number">05</span>:<span class="token number">00</span></code></pre></div>
推荐文章
发财的黄花菜
·
Django ForeignKey 反向查询中 filter 和 _set的效率对比_django 外键 反向查询效率-CSDN博客
1 月前
温暖的酱牛肉
·
mysql-tutorial/articles/sub-query.md at master · guobinhit/mysql-tutorial · GitHub
6 月前
爱玩的小笼包
·
IF THEN Statement in SQL Server - From Basics to Advanced
8 月前
幸福的书签
·
杭州八所重高差距有多大? - 知乎
9 月前
热心肠的莲藕
·
查询和响应ECS系统事件 - 云服务器 ECS - 阿里云
1 年前