Setting Seconds Since Epoch for 9am Tommorow

81 views
Skip to first unread message

Harry

unread,
Jul 24, 2025, 3:09:46 PMJul 24
to Tasker
I have been racking my  brain on this for 2 days. The following makes sense to me but does not yield the correct seconds (at least not according to Gemini):

    Task: Get Tomorrow At 9:00 A.M.


    A1: Parse/Format DateTime [

         Input Type: Now (Current Date And Time)

         Input: 9 AM tomorrow

         Input Format: s

         Output Format: yyyy-MM-dd

         Formatted Variable Names: %current_date

         Output Offset Type: Days

         Output Offset: 1

         Time Zone: EST ]

    

    A2: Variable Set [

         Name: %current_date_time

         To: %current_date 09:00 ]

    

    A3: Parse/Format DateTime [

         Input Type: Custom

         Input: %current_date_time

         Input Format: yyyy-MM-dd HH:mm

         Output Format: %TIMES

         Formatted Variable Names: %tomorrow_9am_epoch

         Output Offset Type: None ]

    

    A4: Flash [

         Text: %tomorrow_9am_epoch

         Continue Task Immediately: On

         Dismiss On Click: On ]

RSF

unread,
Jul 25, 2025, 2:01:15 AMJul 25
to Tasker
The Parse/Format DateTime action returns the number of seconds since epoch in a built-in variable, %dt_seconds. Therefore, after your A3 action, just inspect %dt_seconds, vs. %tomorrow_9am_epoch. You could just delete the Output Format and Formatted Variables Names parts of A3 -- just rely on that %dt_seconds variable.

Daniel Matthews

unread,
Jul 25, 2025, 2:07:06 AMJul 25
to Tasker
```
Task: Tomorrow 9am Epoch

A1: Flash [
     Text: %DATE

     Continue Task Immediately: On
     Dismiss On Click: On ]

A2: Parse/Format DateTime [
     Input Type: Custom
     Input: %DATE
     Input Format: dd-MM-y
     Output Offset Type: Days
     Output Offset: 1 ]

A3: Flash [
     Text: Tomorrow: %dt_year %dt_month_of_year %dt_day_of_month

     Continue Task Immediately: On
     Dismiss On Click: On ]

A4: Variable Set [
     Name: %tomorrow9amEpoch
     To: %dt_seconds + (60 * (9 * 60))
     Do Maths: On
     Max Rounding Digits: 3
     Structure Output (JSON, etc): On ]

A5: Flash [
     Text: Tomorrow 0900 epoch: %tomorrow9amEpoch

     Continue Task Immediately: On
     Dismiss On Click: On ]


```

This works, of course there are many ways to get what you want

Harry

unread,
Jul 25, 2025, 6:40:39 AMJul 25
to Tasker
Thank you very much for the help. I did get an error on A2 -  Input Format: dd-MM-y. It returned 25-25-2025. I changed the format to MM-dd-yyyy and it worked fine.

Harry

unread,
Jul 25, 2025, 9:05:48 AMJul 25
to Tasker
I am getting crazy seconds since Epoch when I flash  %dt_seconds=-61360398238  in A2  and of course A4 is out of the ballpark.

    Task: Test Epoch

    

    A1: Parse/Format DateTime [

         Input Type: Custom

         Input: %DATE

         Input Format: MM-dd-yyyy

         Output Offset Type: Days

         Output Offset: 1 ]

    

    A2: Flash [

         Text: %dt_seconds

         Continue Task Immediately: On

         Dismiss On Click: On ]

    

    A3: Flash [

         Text: %dt_month_of_year %dt_day_of_month %dt_year

         Continue Task Immediately: On

         Dismiss On Click: On ]

    

    A4: Variable Set [

         Name: %Tommorow_9amEpoch

         To: %dt_seconds + (60*(9*60))

         Do Maths: On

         Max Rounding Digits: 3

         Structure Output (JSON, etc): On ]


RSF

unread,
Jul 25, 2025, 10:54:56 AMJul 25
to Tasker
Since the built-in %DATE variable uses only a two-digit year (e.g. 7-25-25), your input format in A1 should be
 Input Format: MM-dd-yy
instead of 
 Input Format: MM-dd-yyyy

Daniel Matthews

unread,
Jul 28, 2025, 7:42:12 AMJul 28
to tas...@googlegroups.com
No worries 😁 

--
You received this message because you are subscribed to a topic in the Google Groups "Tasker" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tasker/2w1b6v7GALQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tasker+un...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/tasker/f1decb0b-9de0-4b35-a0f7-7f4ec2592a3an%40googlegroups.com.

aa6vh

unread,
Jul 28, 2025, 10:52:11 AMJul 28
to Tasker
Remember that the tasker %TIMES and %TIMEMS variables are UTC based, not local time based. If you use the supplied conversion routines, the time zone difference (and summer time) should be compensated for you. But if you do direct calculations on the %TIMES or %TIMEMS values, your results may be off by the time zone difference.

For example, a value of zero for %TIMES will represent January 1, 1970 at 0:00 hours UTC, but in my time zone (Pacific, or UTC-8) it represents December 31, 1969 at 16:00 hours.
Message has been deleted
Message has been deleted

Harry

unread,
Aug 4, 2025, 6:48:49 AMAug 4
to Tasker
Thanks to everyone, the routine is working as expected

Harry

unread,
Aug 4, 2025, 6:48:49 AMAug 4
to Tasker
Thanks to everyone for the help. It's working just as I would expect it to.

On Monday, July 28, 2025 at 10:52:11 AM UTC-4 aa6vh wrote:
Reply all
Reply to author
Forward
0 new messages