Easy Qestion about FileGetTime Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
masheen
Posts: 295
Joined: 06 Dec 2016, 14:10

Easy Qestion about FileGetTime

16 Oct 2017, 18:32

How to get file create day
i read help but cant understand

Code: Select all

FileGetTime, output, D:\123.txt
Msgbox % output ;need only day example 17
User avatar
JoeWinograd
Posts: 2206
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: Easy Qestion about FileGetTime  Topic is solved

16 Oct 2017, 19:02

You could simply use SubStr to get all of the date/time components. For example:

Code: Select all

FileGetTime,DateTime,D:\123.txt
Year:=SubStr(DateTime,1,4)
Month:=SubStr(DateTime,5,2)
Day:=SubStr(DateTime,7,2)
Also, note at the documentation that the default is Modification time, so if you really want Creation time, you'll need to specify C as the fourth parameter, i.e.:

Code: Select all

FileGetTime,DateTime,D:\123.txt,C
Regards, Joe
teadrinker
Posts: 4357
Joined: 29 Mar 2015, 09:41
Contact:

Re: Easy Qestion about FileGetTime

16 Oct 2017, 19:22

Also, you could use FormatTime:

Code: Select all

FileGetTime, DateTime, % A_AhkPath, C
MsgBox, % DateTime

FormatTime, Year, % DateTime, yyyy
FormatTime, Month, % DateTime, MM
FormatTime, Day, % DateTime, dd
MsgBox, Year = %Year%`nMonth = %Month%`nDay = %Day%

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], Chunjee, serenite and 91 guests