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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:21:14+00:00 2026-05-23T07:21:14+00:00

It would make sense if I was in a ±5 hour timezone, but I’m

  • 0

It would make sense if I was in a ±5 hour timezone, but I’m in GMT -06:00, so I’m not sure if timezones are my problem or if it’s something else. Here is my code I’m using:

Private Sub SetFileTimes(file As String, Optional creationTime As Date, Optional accessTime As Date, Optional writeTime As Date)
    Dim handle As Long
    Dim sysCreationTime As FileTime, sysAccessTime As FileTime, sysWriteTime As FileTime
    Dim SECURITY_ATTRIBUTES As SecurityAttributes
    SECURITY_ATTRIBUTES.nLength = Len(SECURITY_ATTRIBUTES)
    SECURITY_ATTRIBUTES.lpSecurityDescriptor = 0
    SECURITY_ATTRIBUTES.bInheritHandle = False
    handle = CreateFile(file & Chr$(0), GENERIC_READ Or GENERIC_WRITE, FILE_SHARE_READ Or FILE_SHARE_WRITE, SECURITY_ATTRIBUTES, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0&)
    Debug.Assert handle <> -1
    GetFileTime handle, sysCreationTime, sysAccessTime, sysWriteTime

    If creationTime <> 0 Then
        SystemTimeToFileTime GetSystemTime(creationTime), sysCreationTime
    End If
    If accessTime <> 0 Then
        SystemTimeToFileTime GetSystemTime(accessTime), sysAccessTime
    End If
    If writeTime <> 0 Then
        SystemTimeToFileTime GetSystemTime(writeTime), sysWriteTime
    End If

    SetFileTime handle, sysCreationTime, sysAccessTime, sysWriteTime
    CloseHandle handle
End Sub

Private Function GetSystemTime(datetime As Date) As SystemTime
    GetSystemTime.Year = Year(datetime)
    GetSystemTime.Month = Month(datetime)
    GetSystemTime.Day = Day(datetime)
    GetSystemTime.Hour = Hour(datetime)
    GetSystemTime.Minute = Minute(datetime)
    GetSystemTime.Second = Second(datetime)
    GetSystemTime.Milliseconds = 0
End Function

The function works, but all of my times are 5 hours early. (I.E. If I try and set the date to 10am, it will set it to 5am instead.) The default times (ones I do not specify) do not change, as expected. While debugging, I can see that SystemTimeToFileTime is returning a value less than it should be. What can I do to fix this?

  • 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-23T07:21:14+00:00Added an answer on May 23, 2026 at 7:21 am

    During daylight savings time, Chicago (usually GMT-06) is GMT-05.

    Edit: Added link to FileTimeToLocalTime.

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

Sidebar

Related Questions

Now that it is possible to make non-container-bound webapps, it would make sense to
Is the type check a mere integer comparison? Or would it make sense to
I'm curious what tag would make the most semantic sense to encapsulate a group
Logically, it would make sense to use the grep command, as that supports regular
Most modifiers make sense to me - abstract, protected etc. But virtual seems a
If so, how? Does this question even make sense? In my case it would
Edited to make my actual goal more clear... Not sure if this is even
Can anyone help me see in what kind of scenarios it would make sense
I have an application where it seems as if it would make sense to
I am a .NET developer, what JavaScript code editor would make sense to use

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.