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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:32:58+00:00 2026-06-10T07:32:58+00:00

I am trying to set system date (not time) using following code. I want

  • 0

I am trying to set system date (not time) using following code. I want to set the current time to the new date. Following is a sample code and I found the time is not correct after change.

day = 20
month = 3
year = 2010

timetuple = time.localtime()
print timetuple
print timetuple[3], timetuple[4], timetuple[5]
win32api.SetSystemTime(year, month, timetuple[6]+1, 
    day, timetuple[3], timetuple[4], timetuple[5], 1)
  • 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-10T07:33:00+00:00Added an answer on June 10, 2026 at 7:33 am

    You are setting the system time from the localtime timestamp. The latter is adjusted for the local timezone, while SetSystemTime requires you to use the UTC timezone.

    Use time.gmtime() instead:

    tt = time.gmttime()
    win32api.SetSystemTime(year, month, 0, day, 
        tt.tm_hour, tt.tt_min, tt.tt_sec, 0)
    

    You then also avoid having to deal with whether or not you are in summer time (DST) now, vs. March when you would be in winter time.

    Alternatively you can use a datetime.datetime.utcnow() call and get the millisecond parameter as a bonus:

    import datetime
    tt = datetime.datetime.utcnow().time()
    win32api.SetSystemTime(year, month, 0, day,
        tt.hour, tt.minute, tt.second, tt.microsecond//1000)
    

    Note that I left the weekday item set to 0 in both examples; it is ignored when calling SetSystemTime. If it was not ignored, then your code example had the value wrong; the Python value ranges from 0 to 6 for Monday through to Sunday, while the Win32 API wants 1 through to 7 for Sunday through to Saturday. You’d have to add 2 and use modulo 7:

    win32_systemtime_weekday = (python_weekday + 2) % 7)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to set my columns default date time to system datetime. It
I am trying to set up an automated build system on Windows using Cygwin.
I'm using a ModelForm, but not using Django's auth system. I am also trying
I'm trying to compare two dates with the current date. It seems not to
I'll try my best to explain how I'm trying to set up this system.
Im trying to set up a PayPal IPN system on my site, but I
I'm trying to set up a simple chat system with jQuery / Ajax ,
I am trying to set up a pretty basic messaging system with ActiveMQ. I
I am currently playing with Qt trying to set up a small particle system.
I'm using RichFaces 3.3.3 and been trying to figure out how to set the

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.