Current time in seconds?

831 views
Skip to first unread message

Walter Francis

unread,
Aug 22, 2011, 2:57:10 PM8/22/11
to Tasker
I have some data I'd like to send to my website (URL has a parameter
with current date and time on the client upload), plus some other
reasons (log timestamps, etc) which I'd like to have easy access to
current time in seconds. %TIME of course is HH.MM, and I'm unaware of
an easy time to extract current time in seconds from %TIMES (anyone?)
so I'm left with something silly like Locale Execute date >/sdcard/
date.txt and reading that file.

Is there a better solution here? I am sure I'm missing something. :)

BossMan

unread,
Aug 22, 2011, 3:26:14 PM8/22/11
to tas...@googlegroups.com
There is at least one thing you can do easier: replace Locale Execute with Secure Settings and read the %STDOUT (instead of a file).

As for %TIMES - there are some options for time/date convertion in the Variable Convert action - haven't check them, but maybe one of them will suit your needs.

If not, then you can try doing some manual calculations: add a periodic task that will be run, say every hour. In that task, store the current %TIMES value in a separate variable (e.g. $MY_TIMES). Then, in a task where you need the seconds, do (%TIMES - %MY_TIMES)/60, take the fractional part, multiply by 60 and you're done ;) BTW, this is just a wild guess, not tested :)

BR,
A.

Pent

unread,
Aug 22, 2011, 4:40:20 PM8/22/11
to Tasker
Good answer that one :-)

Pent

Walter Francis

unread,
Aug 22, 2011, 9:04:49 PM8/22/11
to Tasker
On Aug 22, 3:26 pm, BossMan <adam.marynow...@gmail.com> wrote:
> There is at least one thing you can do easier: replace Locale Execute with
> Secure Settings and read the %STDOUT (instead of a file).

I think I'll probably go for this one, since it's a bit more redirect
than back and forth with a file etc. Didn't realize it'd set %STDOUT,
good stuff.

> As for %TIMES - there are some options for time/date convertion in the
> Variable Convert action - haven't check them, but maybe one of them will
> suit your needs.

Yeah, not seeing anything there. I guess Pent agrees. Haven't tried
seconds to long date time, but unless %TIMES is epoch, that won't
help.

> If not, then you can try doing some manual calculations: add a periodic task
> that will be run, say every hour. In that task, store the current %TIMES
> value in a separate variable (e.g. $MY_TIMES). Then, in a task where you
> need the seconds, do (%TIMES - %MY_TIMES)/60, take the fractional part,
> multiply by 60 and you're done ;) BTW, this is just a wild guess, not tested

Yeah, I've done this before, and I really wanted to avoid it ;)

And THANKS Pent. Add a seconds variable somewhere :P

Pent

unread,
Aug 23, 2011, 5:04:27 AM8/23/11
to Tasker
> > As for %TIMES - there are some options for time/date convertion in the
> > Variable Convert action - haven't check them, but maybe one of them will
> > suit your needs.
>
> Yeah, not seeing anything there.  I guess Pent agrees.  Haven't tried
> seconds to long date time, but unless %TIMES is epoch, that won't
> help.

%TIMES is the 1970-base thing :-)

Variable convert Seconds to Date Time only gives hours and minutes
unfortunately. I'll have a look see if it's easy to get mod in for
next release
so you can do %TIMES mod 60.

Pent

Walter Francis

unread,
Aug 23, 2011, 8:07:23 AM8/23/11
to Tasker
On Aug 23, 5:04 am, Pent <supp...@apps.dinglisch.net> wrote:

> %TIMES is the 1970-base thing :-)

I know, not epoch I guess? Seconds since Midnight UTC Jan 1 1970 of
course..

> Variable convert Seconds to Date Time only gives hours and minutes
> unfortunately. I'll have a look see if it's easy to get mod in for
> next release
> so you can do %TIMES mod 60.

Yep, that'll do! :D

Bossman,

Thanks for the Secure Settings tip, that plugin is awesome. I haven't
used it much beyond seeing how it worked last night and setting up a
sample extraction of seconds from it, but it looks to be a really nice
extension on Tasker. :)

Dave

unread,
Jan 23, 2014, 10:00:22 AM1/23/14
to tas...@googlegroups.com
I too am really interested in a date stamp that includes seconds (hh:mm:ss). It looks like a MOD 60 would be THE way to go.

Q1: Did it ever get incorporated?

Q2: Could Boss Man's suggestion 
"If not, then you can try doing some manual calculations: add a periodic task that will be run, say every hour. In that task, store the current %TIMES value in a separate variable (e.g. $MY_TIMES). Then, in a task where you need the seconds, do (%TIMES - %MY_TIMES)/60, take the fractional part, multiply by 60 and you're done ;) BTW, this is just a wild guess, not tested :)
be translated in to a single call by incorporating the "hourly step" he mentions into the equation?
Reply all
Reply to author
Forward
0 new messages