is there an easy way to make tasker show current time correctly?

1,790 views
Skip to first unread message

no nick

unread,
May 8, 2015, 4:14:43 PM5/8/15
to tas...@googlegroups.com
i have something setup (finally) which works fine and pulls data from a train site to show me arrival/departure times but i want to run an action if the time in the variable matches the system time. problem is, the %train_time variable has 19:30 and taskers %time has 19.30, so : vs .

i've seen very long winded ways here to try and get it to show correctly (with a ":" not a "." ) but in my task, it's all done and working bar an if statement at the end so i just need some way of the current system time being shows correctly without going through everything else i've gone?

i've tried: (the below was a nice suprise on getting the day, month, year etc (minus the "5" on the 4th line - learned something new again)
  1. Variable set %realtime to %times
  2. Variable convert %realtime to seconds to long date time
  3. Variable split
  4. Say %realtime5

and that works but i need to then convert it to 24hour format so 19:30 not 9:30pm. i've tried variable convert but that doesn't cover this.

i tried instead of changing 2 above from long to medium and on 4 choosing %realtime4 and now i get a proper 24hr clock with the : - 19:30 - yay.

i'll be honest, i've been writing this post (and googling while doing it) since 19:30 and it's now 21:14 and was going to beg for help but seems that this might sort it.


so in spite of that - Pent, please, pretty please can you add a variable that shows time with the colon?  as well as the full stop which i've read is needed for something else (altough my mind is a blur right now).


thank you all and a good night ;)


Tom.

Juergen Gruen

unread,
May 8, 2015, 5:01:47 PM5/8/15
to tas...@googlegroups.com

Maybe I got it wrong, but why not just replace the dot by a colon?

A1 Variable Set
      Name %realtime
      Value %TIME

A2 Variaple Search Replace
      Name %realtime
      Replace Mathes on
      Search \.
      Replace With :

A3 Flash
     %realtime

Juergen.


  1. Variable se%realtime to %TIME
  2. Variable Search Replace  %realtime to seconds to long date time
  3. Variable split
  4. Say %realtime5



Juergen Gruen

unread,
May 8, 2015, 5:03:23 PM5/8/15
to tas...@googlegroups.com


On Friday, May 8, 2015 at 4:01:47 PM UTC-5, Juergen Gruen wrote:
  1. Variable se%realtime to %TIME
  2. Variable Search Replace  %realtime to seconds to long date time
  3. Variable split
  4. Say %realtime5

Just forget this part...

no nick

unread,
May 8, 2015, 5:23:12 PM5/8/15
to tas...@googlegroups.com
wouldn't the output from :

    1. Variable set %realtime to %times
    1. Variable convert %realtime to seconds to demium
    2. Variable split
    3. Say %realtime4

    be ok?  i haven't tested yet but it gives out a time which is in a 24hr format with a : as a seperator.

    Juergen Gruen

    unread,
    May 8, 2015, 5:54:43 PM5/8/15
    to tas...@googlegroups.com
    I wrote "just forget this part" because I had this copy/paste-error after my name, in my first answer. Did not want to confuse you...

    Your solution will work, I guess. But you asked, and my suggestion is one action less ;-)

    Finally, I would not agree to add another Build-In variable. Better include an option "Variable Convert, Seconds To DateTimeFormatString". Nice implementation/workaround with a subtask here: http://tasker.wikidot.com/getformatteddate

    Juergen.


    Robert Ryan

    unread,
    May 8, 2015, 6:12:01 PM5/8/15
    to Support Forum


    On May 8, 2015 3:54 PM, "Juergen Gruen" <androi...@googlemail.com> wrote:
    >
    > Nice implementation/workaround with a subtask here: http://tasker.wikidot.com/getformatteddate

    I would prefer http://developer.android.com/reference/java/text/DateFormat.html which is more flexible and efficient than getformatteddate.

    Juergen Gruen

    unread,
    May 8, 2015, 6:15:13 PM5/8/15
    to tas...@googlegroups.com
    Just an example. I agree, a build-in Tasker solution should use the native API...

    Juergen.

    me

    unread,
    May 8, 2015, 6:39:02 PM5/8/15
    to tas...@googlegroups.com
    another pair of eyes is good to have. might come in handy :)

    would be useful to just have the correct setup within tasker though by default as 10.59 isn't a time, it's a number

    On 8 May 2015 at 23:15, Juergen Gruen <androi...@googlemail.com> wrote:
    Just an example. I agree, a build-in Tasker solution should use the native API...

    Juergen.

    --
    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/QeiVku9INe0/unsubscribe.
    To unsubscribe from this group and all its topics, send an email to tasker+un...@googlegroups.com.
    Visit this group at http://groups.google.com/group/tasker.
    For more options, visit https://groups.google.com/d/optout.

    Juergen Gruen

    unread,
    May 8, 2015, 7:31:40 PM5/8/15
    to tas...@googlegroups.com
     it's a number

    ...not in Germany ;-)

    Rich D

    unread,
    May 8, 2015, 8:03:51 PM5/8/15
    to Tasker Google Groups Post

    You can get the time in 12 hr format with this shell command as well..

    date +"%r"

    no nick

    unread,
    May 8, 2015, 8:14:09 PM5/8/15
    to tas...@googlegroups.com


    On Saturday, 9 May 2015 01:03:51 UTC+1, Rich D wrote:

    You can get the time in 12 hr format with this shell command as well..

    date +"%r"

    ta all :)

    will try diff ways and find which works best for me.

    still think the option should be there though for a choice of . or :  - it cases so many probs for some of us (outside germany :p )

    Juergen Gruen

    unread,
    May 8, 2015, 9:01:24 PM5/8/15
    to tas...@googlegroups.com
    ... to clarify: I only said 10.59 is not a number in Germany. For a time ":" is also more common than "."

    ... and I think Date/Time-formatting in Tasker causes way more probs in non-english speaking countries.


    Juergen.

    Robert Ryan

    unread,
    May 8, 2015, 9:47:38 PM5/8/15
    to Support Forum


    On May 8, 2015 7:01 PM, "Juergen Gruen" <androi...@googlemail.com> wrote:
    >
    > ... and I think Date/Time-formatting in Tasker causes way more probs in non-english speaking countries.

    This one of the reasons I suggested the DateFormat class. It can automatically adjust its output to the user's locale.

    Robert Ryan

    unread,
    May 8, 2015, 10:00:03 PM5/8/15
    to Support Forum

    Example:

    Test (39)
    A1: Variable Set [ Name:%time_ms To:%TIMEMS Do Maths:Off Append:Off ]
    A2: Java Function [ Return:time_form Class Or Object:DateFormat Function:getTimeInstance
    {DateFormat} (int) Param:3 Param: Param: Param: Param: Param: Param: ]
    A3: Java Function [ Return:%time_str Class Or Object:time_form Function:format
    {String} (Object) Param:%time_ms Param: Param: Param: Param: Param: Param: ]
    A4: Flash [ Text:%time_str Long:Off ]
    A5: Java Function [ Return:sdf Class Or Object:SimpleDateFormat Function:new
    {SimpleDateFormat} (String) Param:"kk:mm:ss" Param: Param: Param: Param: Param: Param: ]
    A6: Java Function [ Return:%time_str Class Or Object:sdf Function:format
    {String} (Object) Param:%time_ms Param: Param: Param: Param: Param: Param: ]
    A7: Flash [ Text:%time_str Long:Off ]

    Juergen Gruen

    unread,
    May 9, 2015, 2:14:18 AM5/9/15
    to tas...@googlegroups.com
    Thank you for the example, but

    "I hope this can get improved in a future version. It seems to be a very clumsy way to set a simple" date string. ;-)

    Thank you also for a nice new word in my english vocabulary ;-)


    Juergen.

    Robert Ryan

    unread,
    May 9, 2015, 2:59:53 AM5/9/15
    to Support Forum


    On May 9, 2015 12:14 AM, "Juergen Gruen" <androi...@googlemail.com> wrote:
    > It seems to be a very clumsy way to set a simple" date string. ;-)

    I think perhaps you misunderstood. My argument and example were targeted specifically against the suggestion of using getformatteddate. Directly using Java is more efficient and flexible than the javascript presented in that task.

    As far as how Tasker formats the date and time, I think that the device settings should be adhered to. On my device that would make the separator between hours and minutes a colon.

    Juergen Gruen

    unread,
    May 9, 2015, 3:33:45 AM5/9/15
    to tas...@googlegroups.com
    Sorry, but;

    1. I presented the JavaScript example, because I thought this way tasker users can understand the potential of a user-defined format-string better than with a native Java example. And it is an easy workaround as long there is no build in alternative.

    2. As said before, I totally agree with you that using Java API is the better solution...

    3. I used the "clumsy" quote not to make fun about you, but to end this discussion with a little smile (because of the similarity with the final conclusions of the discussion about setting field values with Java Function). It seems, that even with emoticons it is very difficult to express exactly what you want to express...

    Juergen.

    Shane Thoms

    unread,
    May 9, 2015, 12:51:01 PM5/9/15
    to tas...@googlegroups.com
    Split variable %TIME on "." then set (or use directly) a new variable concatenating    %TIME1:%TIME2
    Reply all
    Reply to author
    Forward
    0 new messages