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

  • Home
  • SEARCH
  • 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 7785921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:20:00+00:00 2026-06-01T20:20:00+00:00

Here is how I change the TimeZoneInfo (App #1) : private static void ChangeTimeZone(TimeZoneInfo

  • 0

Here is how I change the TimeZoneInfo (App #1) :

private static void ChangeTimeZone(TimeZoneInfo tzi)
{
    TIME_ZONE_INFORMATION actual = new TIME_ZONE_INFORMATION();
    NativeMethods.GetTimeZoneInformation(out actual);

    if (tzi == null || actual.StandardName == tzi.StandardName)
        return;

    TIME_ZONE_INFORMATION newZone = (TIME_ZONE_INFORMATION)tzi;

    RunWin32Method(() => NativeMethods.SetTimeZoneInformation(ref newZone));

    // Update .NET
    CultureInfo.CurrentCulture.ClearCachedData();
    TimeZoneInfo.ClearCachedData();

    // Notify all windows that we changed a Windows setting.
    // result is True
    IntPtr ptr;
    System.Diagnostics.Debug.WriteLine(NativeMethods.SendMessageTimeout(NativeMethods.HWND_BROADCAST, NativeMethods.WMI_SETTING_CHANGE,
        IntPtr.Zero, IntPtr.Zero, 0x00, 1000, out ptr));
}

When I call my method:

ChangeTimeZone(TimeZoneInfo.GetSystemTimeZones().First(e => !e.SupportsDaylightSavingTime));
// Stopping debugger and watching other .NET App then continue to next instruction
ChangeTimeZone(TimeZoneInfo.GetSystemTimeZones().First(e => e.StandardName.Contains("Romance")));

Here is the other app (App #2):

static void Main(string[] args)
{
    while (true)
    {
        Console.WriteLine(DateTime.Now);
        Thread.Sleep(500);
    }
}

Output of DateTime is never updated to the new TimeZone, why?


EDIT

As @Jon said, by adding CultureInfo.CurrentCulture.ClearCachedData(); the new date will be updated. But as said, I would that ALL other application uses this new TimeZone. I have a lot apps running in background using the DateTime.Now, it would be bad to specify each time to clear the cache before retrieve the local updated date…

  • 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-06-01T20:20:01+00:00Added an answer on June 1, 2026 at 8:20 pm

    I suspect your second app is just using cached time zone data. (It’s in a separate process, after all – clearing the cache in app 1 isn’t going to affect any in-process caches in app 2.) Try calling TimeZoneInfo.ClearCachedData in app 2 and see if that sorts out the issue.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What do I need to change here so that animal contains {3,4}? void funct(unsigned
I am here to change the uppercase table name present in the stored procedures.
I have a similar case as the one described here: Dynamically change RESTEasy service
Here is an example: $(function() { $('#test').change(function() { $('#length').html($('#test').val().length) }) }) <script src=https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js></script> <textarea
Here is the div element on my page: How can I change a class's
Here are my jquery mobile checkboxes i want to change its background color. i
here is the sample: http://jsfiddle.net/Zg55k/ How can I change css background image and color
Here is some javascript that I wrote that attempts to change the theme of
Hey here is my problem : i made a flash and i can`t change
a simple question here Is there a way to change the text click here

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.