Does AHK have a solution for this date Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
indiannat

Does AHK have a solution for this date  Topic is solved

25 Aug 2018, 14:52

There is a date format called webkit used in safari and others

https://www.epochconverter.com/webkit

Sample of a date is 13125639034655213

Does you know how to use it in ahk so I can get a regular date
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Does AHK have a solution for this date

25 Aug 2018, 15:35

- Using the functions in the link specified:

Code: Select all

;convert common date formats (Excel / FileTime / Unix) - AutoHotkey Community
;https://autohotkey.com/boards/viewtopic.php?f=5&t=44727

q:: ;dates - microseconds since 1601 to FILETIME to AHK date
vMcs := 13125639034655213 ;microseconds
vIntervals := vMcs * 10 ;100-nanosecond intervals
vOutput := ""
vOutput .= JEE_DateFileTimeToAhk(vIntervals, "yyyy-MM-dd HH:mm:ss") "`r`n"
vOutput .= vMcs " microseconds" "`r`n"
vOutput .= vIntervals " 100-nanosecond intervals" "`r`n"

vOutput .= "`r`n"

vIntervals := JEE_DateAhkToFileTime("") ;100-nanosecond intervals
vMcs := vIntervals // 10 ;microseconds
vOutput .= JEE_DateFileTimeToAhk("", "yyyy-MM-dd HH:mm:ss") "`r`n"
vOutput .= vMcs " microseconds" "`r`n"
vOutput .= vIntervals " 100-nanosecond intervals" "`r`n"

MsgBox, % vOutput
return
- Here's a more direct answer:

Code: Select all

w:: ;dates - microseconds since 1601 to AHK date
vMcs := 13125639034655213
vDate := 1601
EnvAdd, vDate, % vMcs//1000000, S
MsgBox, % vDate
return

;==================================================

e:: ;dates - time now as milliseconds since 1601
vMcs := ""
EnvSub, vMcs, 1601, S
vMcs *= 1000000
MsgBox, % vMcs
return
- Hmm, Wikipedia didn't mention the 'mcs' abbreviation for microseconds, which I couldn't remember initially.
Microsecond - Wikipedia
https://en.wikipedia.org/wiki/Microsecond
MCS - Wikipedia
https://en.wikipedia.org/wiki/MCS

- The format that you posted is microseconds since 1601.
WebKit/Chrome Timestamp Converter
https://www.epochconverter.com/webkit
- The FILETIME format gives numbers that are 10 times bigger: 100-nanosecond intervals since 1601. AKA 0.1 microsecond intervals since 1601.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
swagfag
Posts: 5458
Joined: 11 Jan 2017, 17:59

Re: Does AHK have a solution for this date

25 Aug 2018, 17:11

Code: Select all

msgbox % convert(13125639034655213)

/*
	timestamp - WebKit/Chrome timestamp
	return - AHK YYYYMMDDHH24MMSS timestamp
*/
convert(timestamp) {
	epochStart := 1601
	timestamp := Round(timestamp / 1000000)
	epochStart += timestamp, Seconds

	return epochStart
}

Return to “Ask For Help”

Who is online

Users browsing this forum: bapl, Bing [Bot], gidean1, Green Astronaut, JohnMartok, kghaleh, sanmaodo, XMCQCX, yalsch and 71 guests