PRO
dbeard
USA
Asked
— Edited
Looking for script code that will convert current time to Unix time. Unix time starts on 01/01/1970. I need to know how to calculate the Unix time for current time.
Thanks
What you are speaking of is actually know as The Unix epoch (or Unix time or POSIX time or Unix timestamp) is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT), not counting leap seconds (in ISO 8601: 1970-01-01T00:00:00Z). Literally speaking the epoch is Unix time 0 (midnight 1/1/1970), but 'epoch' is often used as a synonym for 'Unix time'. Many Unix systems store epoch dates as a signed 32-bit integer.
Is that right?
I am trying to calculate the Unix Epoch time for now. Which is at this very moment, 1521648159. But cant get it to work via script.
Script:
online converter tool: https://www.epochconverter.com/
I had a deja vu moment... remember this thread: https://synthiam.com/Community/Questions/9760
Are you still playing with Dates ?
Absolutely. Reviewed and tried may times, but couldn't get the calculated time to equal the actual UNIX Epoch time, was off by about 15 hours. Not sure why.
will try the example above and see how it does, appreciate the reminder.
@dbeard:
Fixed a silly mistake: UnixEpoch starts at midnight (0:0).
relevant thread: https://synthiam.com/Community/Questions/9760
DJ's post #8 is the reason.
Have to adjust for UTC, but I also was making a mistake in my days to hours calc. I couldnt find it since my error was 15 hours and not 24 so I spent my time looking at the hours and seconds calc. Sometimes cant see the Forest cause of the trees.
Thanks, working now.
Believe me I reviewed all my past time posts before posting this because I know how beat up I was going to get.
Really appreciate the assistance.
@dbeard: UnixEpoch is a sequencial time line (seconds since 1970), there is no concept of timezones, UTC date time is used to be immune to the Daylight savings and creating calculating issues.
Also is interesting to notice that many *nix servers can go years without a reboot, so UnixEpoch makes the life easier to count or compare different time moments.