<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/5-things-about-datetime-time-zones-and-formatting-wr2rokaga" -->

---
title: 5 things about DateTime time zones and formatting
description: A practical walkthrough of common DateTime pitfalls in C#, covering why DateTime.Now is risky compared to DateTime.UtcNow, how DateTimeKind affects...
canonical: https://daily.dev/posts/5-things-about-datetime-time-zones-and-formatting-wr2rokaga
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: 5 things about DateTime time zones and formatting | daily.dev
og:description: A practical walkthrough of common DateTime pitfalls in C#, covering why DateTime.Now is risky compared to DateTime.UtcNow, how DateTimeKind affects...
og:url: https://daily.dev/posts/5-things-about-datetime-time-zones-and-formatting-wr2rokaga
og:image: https://api.daily.dev/og/posts/wr2rOKAGa.png
og:image:alt: 5 things about DateTime time zones and formatting
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# 5 things about DateTime time zones and formatting

**[Code4IT](https://daily.dev/sources/code4it)** · 7 min read · 0 upvotes · 0 comments

## Summary

A practical walkthrough of common DateTime pitfalls in C#, covering why DateTime.Now is risky compared to DateTime.UtcNow, how DateTimeKind affects conversions, format shorthands and culture-specific formatting, creating custom cultures, extracting timezone info with zz/zzzz formats, and using the round-trip O format for safely storing and parsing dates.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.code4it.dev/blog/5-things-datetime-timezones-and-formatting>

## Questions this post answers

### Should I use DateTime.Now or DateTime.UtcNow in C#?

Use DateTime.UtcNow instead of DateTime.Now when exchanging dates between systems with different time zones. DateTime.Now returns local time, which can cause inconsistencies, while UtcNow avoids time zone-related bugs. When constructing a DateTime manually, explicitly set DateTimeKind.Utc since the default constructor produces an Unspecified kind with unpredictable conversion behavior.

_daily.dev surfaces practical .NET tips like this for developers hardening date handling in production systems._

### What is the best C# DateTime format for storing dates so they can be parsed back without losing information?

Use the round-trip format specifier "O" (or lowercase "o") when calling ToString on a DateTime. It produces a string like 2020-06-02T15:55:16.0000000Z that can be parsed back with DateTime.ParseExact using the same "O" format, guaranteeing the parsed value equals the original without any loss of information.

_Developers choosing a safe DateTime storage format can find patterns like this through daily.dev._

### How do I get just the time zone offset from a DateTime in C# without the date or time?

Use the "zz" or "zzzz" custom format specifiers on ToString, for example d.ToString("zzzz") returns a string like +02:00. This approach ignores the DateTimeKind and local culture settings entirely, giving only the UTC offset, which is useful when only timezone information is needed rather than a full timestamp.

_daily.dev helps engineers track small but easy-to-miss C# formatting tricks like this one._

## Similar posts on daily.dev

- [10 best practices for timestamps and time zones in databases](https://daily.dev/posts/10-best-practices-for-timestamps-and-time-zones-in-databases-xhfzsegaw) · Tinybird · 2 upvotes · 1 comments
- [PHP date format guide with practical examples](https://daily.dev/posts/php-date-format-guide-with-practical-examples-mtz6p5v6k) · Benjamin Crozat · 6 upvotes · 0 comments
- [Untimely](https://daily.dev/posts/untimely-juzvk8nyx) · The Daily WTF · 1 upvotes · 0 comments
- [Stop Pretending TimeProvider Doesn't Exist — Daily DevOps & .NET](https://daily.dev/posts/stop-pretending-timeprovider-doesn-t-exist-daily-devops-net-8lez0ga1i) · We Are .NET · 21 upvotes · 1 comments

---

Tags: [#.net](https://daily.dev/tags/.net), [#c#](https://daily.dev/tags/c#), [#localization](https://daily.dev/tags/localization)

[View this post on daily.dev](https://daily.dev/posts/5-things-about-datetime-time-zones-and-formatting-wr2rokaga)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"5 things about DateTime time zones and formatting","url":"https://daily.dev/posts/5-things-about-datetime-time-zones-and-formatting-wr2rokaga","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/5-things-about-datetime-time-zones-and-formatting-wr2rokaga"},"datePublished":"2026-10-04T13:06:35.829Z","dateModified":"2026-10-04T13:13:29.960Z","description":"A practical walkthrough of common DateTime pitfalls in C#, covering why DateTime.Now is risky compared to DateTime.UtcNow, how DateTimeKind affects...","image":"https://media.daily.dev/image/upload/s--58gMhC4P--/f_auto/v1722860399/public/Placeholder%2012","thumbnailUrl":"https://media.daily.dev/image/upload/s--58gMhC4P--/f_auto/v1722860399/public/Placeholder%2012","isAccessibleForFree":true,"articleSection":"Code4IT","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Code4IT","logo":"https://media.daily.dev/image/upload/s--OaaG4G10--/f_auto,q_auto/v1791119049/logos/code4it?_a=BAMAMicg0","url":"https://daily.dev/sources/code4it"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/5-things-about-datetime-time-zones-and-formatting-wr2rokaga","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":".net,c#,localization","timeRequired":"PT7M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Code4IT","item":"https://daily.dev/sources/code4it"},{"@type":"ListItem","position":3,"name":"5 things about DateTime time zones and formatting"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/5-things-about-datetime-time-zones-and-formatting-wr2rokaga#faq","mainEntity":[{"@type":"Question","name":"Should I use DateTime.Now or DateTime.UtcNow in C#?","acceptedAnswer":{"@type":"Answer","text":"Use DateTime.UtcNow instead of DateTime.Now when exchanging dates between systems with different time zones. DateTime.Now returns local time, which can cause inconsistencies, while UtcNow avoids time zone-related bugs. When constructing a DateTime manually, explicitly set DateTimeKind.Utc since the default constructor produces an Unspecified kind with unpredictable conversion behavior. daily.dev surfaces practical .NET tips like this for developers hardening date handling in production systems."}},{"@type":"Question","name":"What is the best C# DateTime format for storing dates so they can be parsed back without losing information?","acceptedAnswer":{"@type":"Answer","text":"Use the round-trip format specifier \"O\" (or lowercase \"o\") when calling ToString on a DateTime. It produces a string like 2020-06-02T15:55:16.0000000Z that can be parsed back with DateTime.ParseExact using the same \"O\" format, guaranteeing the parsed value equals the original without any loss of information. Developers choosing a safe DateTime storage format can find patterns like this through daily.dev."}},{"@type":"Question","name":"How do I get just the time zone offset from a DateTime in C# without the date or time?","acceptedAnswer":{"@type":"Answer","text":"Use the \"zz\" or \"zzzz\" custom format specifiers on ToString, for example d.ToString(\"zzzz\") returns a string like +02:00. This approach ignores the DateTimeKind and local culture settings entirely, giving only the UTC offset, which is useful when only timezone information is needed rather than a full timestamp. daily.dev helps engineers track small but easy-to-miss C# formatting tricks like this one."}}]}
```

