How to Get a String with the Date in a YYYY-MM-DD Format?

130 views
Skip to first unread message

Zohar

unread,
Aug 29, 2016, 10:01:35 AM8/29/16
to Tasker
Hi


I am currently getting a string with the current Date, using %DATE.

The problem is that it gives the date as DD-MM-YYYY, and I need it as YYYY-MM-DD :)


What is the simplest/shortest way to achieve it?

I don't want to create a task flooded with many actions, just for getting a YYYY-MM-DD date..

Maybe I can do it in 1 action via a JavaScript action?


Thank you

Zohar

unread,
Aug 29, 2016, 10:02:25 AM8/29/16
to Tasker
Tiny update:

I meant:  via JavaScriptlet action

Svampsson Svampsson

unread,
Aug 29, 2016, 10:10:42 AM8/29/16
to Tasker
Just a note: the easiest way to do it without Java would be to use the AutoTools plugin. It has a built in "format date" action.

Zohar

unread,
Aug 29, 2016, 10:20:25 AM8/29/16
to Tasker
Thank you Svampson
I will check it out..

But for this program, I hope there is a Mid() function that I can use, inside a JavaScriptlet..

That way I can achieve this via: Mid(%DATE,7,4)+Mid(%DATE,4,2)+Mid(%DATE,1,2)

easiuser

unread,
Aug 29, 2016, 11:31:07 AM8/29/16
to Tasker
Try this:


DateChange (656)
 A1: Variable Set [ Name:%today To:29-8-2016 Do Maths:Off Append:Off ]
 A2: Variable Search Replace [ Variable:%today Search:(\d+)(-)(\d+)(-)(\d+) Ignore Case:Off Multi-Line:Off One Match Only:Off Store Matches In: Replace Matches:On Replace With:$5-$3-$1 ]
 A3: Flash [ Text:%today Long:Off ]

Juergen Gruen

unread,
Aug 29, 2016, 1:39:37 PM8/29/16
to Tasker
Hi,
one action:

Test (88)
A1: Run Shell [ Command:date +%F Timeout (Seconds):0 Use Root:Off Store Output In:%date Store Errors In: Store Result In: ]

Juergen.

CoolRaoul

unread,
Sep 3, 2016, 10:47:42 AM9/3/16
to Tasker
one action:

Test (88)
        A1: Run Shell [ Command:date +%F Timeout (Seconds):0 Use Root:Off Store Output In:%date Store Errors In: Store Result In: ]


+1
The method I'm currently using: quicker, simpler, doesn't depends of any plugin. 
And those with extra formatting needs may check the documentation here:  http://linux.die.net/man/3/strftime which describe all the available options.

 
Reply all
Reply to author
Forward
0 new messages