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 1052493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:06:08+00:00 2026-05-16T17:06:08+00:00

I am working on a C# application and want to display dates so they

  • 0

I am working on a C# application and want to display dates so they are local to the user’s timezone. We have the user’s timezone setting stored in the database, and all dates are stored in the database in UTC which should make this simple. The trick is that I also need to display the timezone offset for each date localized for the user.. The timezone offset should not be the Server’s offset but the user’s offset.

String timezone = (String)sessionCookie["time_zone"];
TimeZoneInfo localTimeZone = TimeZoneInfo.FindSystemTimeZoneById(timezone);
DateTime localDateTime = TimeZoneInfo.ConvertTimeFromUtc(utcDt, localTimeZone);

If i then try to do:

localDateTime.ToString("dd MMM yy - HH:mm:ss (zzz)");

I always get the offset of the server in the zzz portion rather than the offset which I just converted to.. Is there a way to use this format string but have it show the offset of the user.. I know that I can get the offset for this manually by doing:

localTimeZone.GetUtcOffset(localDateTime);

I know this is still pretty simple to format manually I was just wondering if there is a way to format the DateTime object according to a specific timezone rather than the system timezone without reinventing the wheel. The main reason is that I had utility function for converting dates from utc to the local timezone and that function did the work of getting the users timezone and what not and now i’d need to duplicate that work for the date to determine what the UtcOffset is.. I suppose the other thing I could do is have my function return the DateTime and the UtcOffset as a tuple so I don’t have to duplicate the work.. Never used tuples in C# before and not sure our app supports that. Still would be nice if I could simply get the toString function to localize to a specific timezone.

  • 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-16T17:06:08+00:00Added an answer on May 16, 2026 at 5:06 pm

    Try using DateTimeOffset:

    DateTimeOffset utcDto = new DateTimeOffset(utcDt, TimeSpan.Zero);
    DateTimeOffset localDateTime = TimeZoneInfo.ConvertTime(utcDto, localTimeZone);
    string dateString = localDateTime.ToString("dd MMM yy - HH:mm:ss (zzz)");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a windows application where i want to display orkut user
I'm working on application and I want to connect it to facebook. The user
I have an working application. Now I want to change the table names of
I am working on Ruby on Rails application, with Prototype. I want to display
I am having a Grid in WPF application. I want to display all the
I am working on an email client application in C#. I want to display
I am working on small android application,I want to display newly added items on
I am working on an application where I have to display the list of
I am new to phonegap.In my application i want display alerts.For that i have
I have a Bing Maps Silverlight Application and want to display Traffic Information on

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.