Unix timestamp

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
c7aesa7r
Posts: 209
Joined: 02 Jun 2016, 21:09

Unix timestamp

04 Nov 2020, 03:30

How do i convert this timestamp to a date format, like 2020-04-11, etc

Code: Select all

1604478439708
Also, convert today date to this timestamp format?

I think the format is: year/month/day/hour/min/sec/ms

I tried:

Code: Select all

myNow := A_YYYY A_MM A_DD A_Hour A_Min A_Sec A_MSec
x := human2Unix(myNow)
FileAppend, human2unix: %x% `n, *

y := unix2Human(1604478439708)
FileAppend,  unix2Human: %y% `n, *
return

unix2Human(unixTimestamp) {
	returnDate = 19700101000000
	returnDate += unixTimestamp, s
	return returnDate
}
human2Unix(humanTime) {
	humanTime -= 1970, s
	return humanTime
}
But x is not returning the same format on the value, i think it's not including the ms
And y does not output anything.
hd0202
Posts: 183
Joined: 04 Oct 2013, 03:07
Location: Germany near Cologne

Re: Unix timestamp

04 Nov 2020, 04:16

Code: Select all

unix2Human(unixTimestamp) {
	returnDate = 19700101000000
	returnDate += unixTimestamp//1000, s
	return returnDate
}
Hubert
c7aesa7r
Posts: 209
Joined: 02 Jun 2016, 21:09

Re: Unix timestamp

04 Nov 2020, 04:23

Ty, and to convert this timestamp with ms to date format like 2020-11-04 etc
hd0202
Posts: 183
Joined: 04 Oct 2013, 03:07
Location: Germany near Cologne

Re: Unix timestamp

04 Nov 2020, 11:31

Code: Select all

unix2Human(unixTimestamp) {
	rDate = 19700101000000
	rDate += unixTimestamp//1000, s
	msec := mod(unixTimestamp, 1000)
	formattime, returnDate, rDate, yyyy-MM-dd 
	return returnDate " etc, msec: " msec
}
Hubert

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], kaka2 and 139 guests