How can I insert regular time? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
LAPIII
Posts: 668
Joined: 01 Aug 2021, 06:01

How can I insert regular time?

06 Jan 2022, 16:26

My script only inserts military time:

Code: Select all

!T
FormatTime, Time,, h:mm 
SendInput %CurrentDateTime%
Return
Could I also insert AM, PM, and EST.
User avatar
flyingDman
Posts: 2817
Joined: 29 Sep 2013, 19:01

Re: How can I insert regular time?

06 Jan 2022, 16:39

Use the time formats provide here: https://www.autohotkey.com/docs/commands/FormatTime.htm

To determine the UTC offset (and the timezone) use this:

Code: Select all

tmdif:=a_now
tmdif+=-a_nowUTC
msgbox % tmdif
14.3 & 1.3.7
amateur+
Posts: 655
Joined: 09 Oct 2021, 15:43

Re: How can I insert regular time?

06 Jan 2022, 17:14

@LAPIII, I think, your script inserts nothing because there are two fatal mistakes in it:
Image
Have found any drawback in my code or approach? Please, point it out. /The moderator ordered to remove the rest of the signature, I had obeyed.
And I really apologize for our russian president. Being a citizen of an aggressor country is very shameful. Personally I tried to avoid this trying to defend elections from fraud being a member of the election commission of one of the precincts but only was subjected to a hooligan attack and right before the vote count was illegally escorted from the polling station and spent the night behind bars (in jail) in a result of illegal actions of corrupt policemen.
amateur+
Posts: 655
Joined: 09 Oct 2021, 15:43

Re: How can I insert regular time?  Topic is solved

06 Jan 2022, 17:24

Code: Select all

!T::
CurrentDateTime := A_NowUTC
CurrentDateTime += -5, h
FormatTime, CurrentDateTimeESTshort, % CurrentDateTime, h:mm tt EST
SendInput %CurrentDateTimeESTshort%
Return
Have found any drawback in my code or approach? Please, point it out. /The moderator ordered to remove the rest of the signature, I had obeyed.
And I really apologize for our russian president. Being a citizen of an aggressor country is very shameful. Personally I tried to avoid this trying to defend elections from fraud being a member of the election commission of one of the precincts but only was subjected to a hooligan attack and right before the vote count was illegally escorted from the polling station and spent the night behind bars (in jail) in a result of illegal actions of corrupt policemen.
User avatar
TLM
Posts: 1608
Joined: 01 Oct 2013, 07:52
Contact:

Re: How can I insert regular time?

06 Jan 2022, 17:31

Here's a trick to get your abbreviated standard name:

Code: Select all

For Item in ComObjGet( "winmgmts:\\.\root\CIMV2" ).ExecQuery( "Select * from Win32_TimeZone" )
    StandardName := Item.StandardName

For Each, Word in ( StrSplit( StandardName, " " ), StandardAbrvName := "" )
	StandardAbrvName .= SubStr( Word, 1, 1 )

FormatTime, CurrentDateTime, A_Now, % "h:mm tt " StandardAbrvName

SendInput %CurrentDateTime%
:D
amateur+
Posts: 655
Joined: 09 Oct 2021, 15:43

Re: How can I insert regular time?

06 Jan 2022, 17:49

TLM wrote:
06 Jan 2022, 17:31

Code: Select all

FormatTime, CurrentDateTime, A_Now, % "h:mm tt " StandardAbrvName
:D
Btw, it is better to put %-sign before A_Now, b/c your great script doesn't fail in the end for only one reason: empty string or string of invalid time format are considered as %A_Now%.
Although it doesn't work for Russian locale.
Have found any drawback in my code or approach? Please, point it out. /The moderator ordered to remove the rest of the signature, I had obeyed.
And I really apologize for our russian president. Being a citizen of an aggressor country is very shameful. Personally I tried to avoid this trying to defend elections from fraud being a member of the election commission of one of the precincts but only was subjected to a hooligan attack and right before the vote count was illegally escorted from the polling station and spent the night behind bars (in jail) in a result of illegal actions of corrupt policemen.
User avatar
flyingDman
Posts: 2817
Joined: 29 Sep 2013, 19:01

Re: How can I insert regular time?

06 Jan 2022, 18:04

@TLM Nice, thank you!
14.3 & 1.3.7

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 121 guests