Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6008083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:46:28+00:00 2026-05-23T01:46:28+00:00

I need to convert DateTime+TimeZoneInfo into DateTimeOffset. How do I do this? I assume

  • 0

I need to convert DateTime+TimeZoneInfo into DateTimeOffset.

How do I do this? I assume I have to pass TimeSpan but then I’m not sure if daylight saving times will be handled properly..

Thanks!

UPDATE

TimeZoneInfo timeZone = TimeZoneInfo.FindSystemTimeZoneById("Mountain Standard Time");
return new DateTimeOffset(DateTime.UtcNow, timeZone.BaseUtcOffset);

This code throws exception..

The UTC Offset for Utc DateTime
instances must be 0.\r\nParameter
name: offset

UPDATE 2

Sorry, I didn’t realize that DateTimeOffset contains only offset, it doesn’t contain actual zone information – so I’m accepting answer from @Dave as it is what I will be using..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T01:46:28+00:00Added an answer on May 23, 2026 at 1:46 am

    You should be about to get the difference between DateTime.UtcNow and DateTime.Now

    var now = DateTime.Now;
    var utcNow = now.ToUniversalTime();
    var ts = utcNow - now;
    

    If you are saving the offset, it is usually beneficial to save all dates in UTC (especially in a db) so you won’t have to deal with offsets. You simply convert them before displaying but do all calculations in UTC.

    Edit: If you have a TimeZone object, you can convert a UTC date to the local time for that time zone.

    TimeZone.CurrentTimeZone.ToLocalTime()
    

    OR

    DateTime dt = TimeZoneInfo.ConvertTimeFromUtc()
    

    Here’s some sample code that will list a date in all timezones.

    var dt = new DateTime(2011, 5, 21, 11, 0, 0);
    foreach (var tzi in TimeZoneInfo.GetSystemTimeZones())
    {
        Console.WriteLine(string.Format("Time in {0} is {1}", tzi.DisplayName, TimeZoneInfo.ConvertTimeFromUtc(dt, tzi)));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a System.DateTime object and I need to convert it into a string
I have a SQL-server timestamp that I need to convert into a representation of
I need to have a common function to convert UTC time to EDT. I
I need to convert all DateTime values to String, though out my project, all
I need to convert a database column in a (MSSQL) database table into UNIX
I need to convert an existing (datetime fields) db from local time ut UTC.
I need to convert strings to DateTime objects that are in non-English languages. I've
I need to be able to convert a DateTime object in C# to an
I need to convert the following stored procedure of SQL Server to MySQL. I
I need to convert from a standard Gregorian date to a Julian day number.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.