Jump to content

Default Timezone for NowCalc


Recommended Posts

I am using information from people using AutoIT, one of the bits of information I am using is the current time. It's my understanding that _NowCalc() returns the time according to the users timezone. Instead, I'd rather have it all based on whatever timezone is picked. Like for example if its 2:00PM in cali, id want it to say 5:00PM in the function, because that would be the EST time.

Link to comment
Share on other sites

You can use the following date/time functions. The example converts the local time to UTC but you can use _Date_Time_SystemTimeToTzSpecificLocalTime to convert UTC to any timezone you like.

#include <date.au3>
$tLT = _Date_Time_GetLocalTime()
ConsoleWrite("Current local date/time .: " & _Date_Time_SystemTimeToDateTimeStr($tLT) & @CRLF)
$tUTC = _Date_Time_TzSpecificLocalTimeToSystemTime(DllStructGetPtr($tLT))
ConsoleWrite("Current UTC date/time .: " & _Date_Time_SystemTimeToDateTimeStr($tUTC) & @CRLF)
Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

The $pTimeZone [optional] Pointer to a $tagTIME_ZONE_INFORMATION structure that specifies the time zone of interest. If

0, the function uses the currently active time zone. has me confused.

Whats an example of converting to eastern time? Is there any structure that has the common timezones done already?

Also I wanted the results to be in YYYY/MM/DD HH:MM:SS

Edited by ParoXsitiC
Link to comment
Share on other sites

Whats an example of converting to eastern time? Is there any structure that has the common timezones done already?

Couldn't find an example on the forum but google delivered some good links:

World Clock and the TimeZoneInformation

Time zones information

A script to extract the TZI information from the registry

Also I wanted the results to be in YYYY/MM/DD HH:MM:SS

Change the script to:

#include <date.au3>
$tLT = _Date_Time_GetLocalTime()
ConsoleWrite]("Current local date/time .: " & _Date_Time_SystemTimeToDateTimeStr($tLT,1) & @CRLF)
$tUTC = _Date_Time_TzSpecificLocalTimeToSystemTime(DllStructGetPtr($tLT))
ConsoleWrite("Current UTC date/time .: " & _Date_Time_SystemTimeToDateTimeStr($tUTC,1) & @CRLF)

But please use at least AutoIt 3.6.6.0 for this to work.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...