Page 1 of 1

natural time to unix time

Posted: 24 Jun 2015 16:56
by schuster666
hi,
how to convert from normal time to unix time.
maybe easy, but i dont know :-))

thanx

Re: natural time to unix time

Posted: 24 Jun 2015 19:03
by schuster666
ok,
got it.

today = "{getDate(), dateformat, yyyy.MM.dd}";
todaystamp = getDate(today, "yyyy.MM.dd");

first get the date at midnight
than make timestamp.

Re: natural time to unix time

Posted: 24 Jun 2015 19:14
by Martin
Hi,

I'm not sure what you mean by normal time.

Automagic internally stores a date+time as the number of milliseconds since 1970 (UTC). If you already have a regular date+time in Automagic like variable triggertime, you can just use an action like Notification on Screen: {triggertime} which shows something like 1435172692450. Divide by 1000 in a script or inline to show the Unix time in seconds: Notification on Screen: {triggertime/1000}

If you have a date stored as a string like "24.06.2015 20:00", you can use a script to parse the value into a regular date+time and then process the date+time the same as above.
Script to parse a date:

Code: Select all

d = getDate("24.06.2015 20:00", "dd.MM.yyyy HH:mm");
Regards,
Martin

Re: natural time to unix time

Posted: 24 Jun 2015 19:15
by Martin
I was just a bit too slow, glad you found it :-)