which different formats can tasker convert DATE TIME to SECONDS?

892 views
Skip to first unread message

droopie

unread,
Dec 13, 2015, 2:47:10 PM12/13/15
to Tasker
i tried to search for ways tasker can convert DATE TIME to SECONDS. 

im using an action that is the following
Java Function [ 
     Return:formatter 
     Class Or Object:SimpleDateFormat 
     Function:new{SimpleDateFormat} (String) 
     Param:MM/dd/yyyy hh:mm a ] 

the problem is that when i convert %beginArr(#) Date Time to Seconds, it works fine but if the event is at 12:00 PM (noon) the final output is in 24hr instead of 12hr. here is a quick breakdown:

%beginArr(#) has the date as 12-13-2015 12:00 PM taken from the action above.
variable set %NextBegin to %beginArr(#) so the original variable isnt modified down the task
%beginArr(#) converted date time seconds 
%NextBegin - 900 to take away 15min from the time 
%NextBegin converted seconds to date time
output has %NextBegin as 12-13-2015 23:45 instead of 12-13-2015 11:45 AM

im not sure how i could change the Java Function in a US time format that tasker can read. all i really need is the time from that java function so the date is really not used by me, not sure how the task will preform tho. im using variable select to get the time at the end of the task so i can create a profile with that time context as a variable. so if i need to change the java function to something that plays better with tasker, i dont mind as long as its in 12hr format with minimal date for a flash and say.this is taken from a calendar query HERE. if all else false i can just change it to 24hr format as long as it works. 

Rich D

unread,
Dec 13, 2015, 10:58:30 PM12/13/15
to Tasker Google Groups Post


> im not sure how i could change the Java Function in a US time format that tasker can read.

Try replacing ' hh:mm a' with kk:mm

Example--

> Java Function [ 
>      Return:formatter 
>      Class Or Object:SimpleDateFormat 
>      Function:new{SimpleDateFormat} (String) 

>      Param:MM/dd/yyyy kk:mm] 
>

That should return it in 24 hr format.

To get back to 12 hr format for a say action use variable convert seconds -> long date time . Then split out the time.

droopie

unread,
Jan 27, 2016, 7:06:38 PM1/27/16
to Tasker
It did return it in a proper format of mm/dd/yyyy 18:00. I converted date to seconds but I'm still having problems.
1. The convert second to date gives me a long string which I like visually but I don't know how to use the PM time to make a variable for Time condition.

2. When converting seconds to date time both medium and short format which is fine because it gives me times like 18:00 or 18.00 the problem with that seems to be sheen I do a variable selection the positions change. Example is 1-27-2016 but next month it will be 2-1-2015 1 symbol different. Not sure if I can use regular expression to select the time with dd:dd or dd.dd selection. Same is true for second to date time medium.

Here is a thought tho... Can I somehow take the Java output which is mm/dd/yyyy 18:00 to get the time but give -15min so a new variable would be 17:45?

Rich D

unread,
Jan 27, 2016, 7:37:58 PM1/27/16
to Tasker Google Groups Post

This gives new meaning to the term delayed response...  :)

> It did return it in a proper format of mm/dd/yyyy 18:00. I converted date to seconds but I'm still having problems.
> 1. The convert second to date gives me a long string which I like visually but I don't know how to use the PM time to make a variable for Time condition.

The tasker variable time context will accept times in epoch time (seconds). 

>
> 2. When converting seconds to date time both medium and short format which is fine because it gives me times like 18:00 or 18.00 the problem with that seems to be sheen I do a variable selection the positions change. Example is 1-27-2016 but next month it will be 2-1-2015 1 symbol different. Not sure if I can use regular expression to select the time with dd:dd or dd.dd selection. Same is true for second to date time medium.

If you still need to parse out the numbers, use the 'variable split' action.

Message has been deleted

droopie

unread,
Jan 27, 2016, 8:14:27 PM1/27/16
to Tasker
haha i tried to do it on my own. would look online, lots of hours trying it while sitting on the toilet, nothing helped. came back to the group!

splitter worked lets see how it goes. thanks!

Rich D

unread,
Jan 27, 2016, 8:29:59 PM1/27/16
to Tasker Google Groups Post

> splitter worked lets see how it goes. thanks!

If you need to split on a space you need to set a local variable to a virtual space then use the variable as the splitter.

>

It seems like you can just use %TIMES (epoch time) if you are just trying to set a variable time context. 

Reply all
Reply to author
Forward
0 new messages