formatting time - noob question

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Guest

formatting time - noob question

06 Mar 2017, 01:59

I have been trying to integrate AHK into my daily life for past few weeks and now working on trying to get the script read my emails and post the information about the currently selected email into another program.
Basically doing sort of a report on the incoming emails.
anyway, I am running into an issue where I cannot get the formatting of the time right.
I am trying to get the time of the incoming email formatted to only hours and minutes.
With the script below I am able to pull the time the email came into the inbox in the Outlook and assign it to the variable: CreationTime
but for some reason when I try to change it to HH:mm, all I get is 00:00

Here is my script, please help if you can.

oApp := ComObjActive("Outlook.Application") ; Get Outlook
oExp := oApp.ActiveExplorer ; Get the ActiveExplorer.
oSel := oExp.Selection ; Get the selection.
oItem := oSel.Item(1) ; Get a selected item.
CreationTime := oItem.CreationTime
FormatTime, TTime, %CreationTime%, HH:mm
MsgBox, %CreationTime%`n%TTime%
return

Message box gives me two lines:
3/5/2017 7:15:25 PM
00:00

The TTime is where I am trying to format it to keep only hours and minutes but all I get is zeros
User avatar
aztec3
Posts: 177
Joined: 07 Apr 2014, 12:05

Re: formatting time - noob question

06 Mar 2017, 09:07

Could the problem be in the format of the CreationTIme variable...per documentation:

"Transforms a YYYYMMDDHH24MISS timestamp into the specified date/time format."

Your timestamp for this variable comes out as:

"3/5/2017 7:15:25 PM"
hlywine
Posts: 9
Joined: 06 Mar 2017, 01:41

Re: formatting time - noob question

08 Mar 2017, 02:56

Thank you for the help, that was it, since I am new to this and coding to begin with, it's a struggle for me, but I was able to make it work with the help of DateParse code posted by polyethene. Thanks for pointing out the obvious to me.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: fiaztv1, Pianist and 179 guests