Dave's Brain

Browse - Programming Tips - Win32: How to convert from UTC/GMT to local time?

Date: 2018apr27
OS: Windows
Language: C/C++

Q.  Win32: How to convert from UTC/GMT to local time?
  
A.  Convert utc SYTEMTIME -> utc FILETIME -> local FILETIME -> local SYSTEMTIME like this

void UtcToLocal(const SYSTEMTIME *pstUtc, SYSTEMTIME *pstLocal) { FILETIME ftUtc, ftLocal; SystemTimeToFileTime(pstUtc, &ftUtc); FileTimeToLocalFileTime(&ftUtc, &ftLocal); FileTimeToSystemTime(&ftLocal, pstLocal); }
Based on https://support.microsoft.com/en-ca/help/245786/how-to-convert-from-gmt-utc-time-to-local-time

Add a comment

Sign in to add a comment
Copyright © 2008-2018, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.