I will build that conversion task and post it. Possibly tomorrow will be done.
The Flash actions are just there to show progress. They can be deleted. If this task doesn't work for you, add a short wait step between tbe steps.
If you want to use this format in other tasks, have this run at 1 minute after midnight every day and have the other tasks use %FDATE.
Date Conversion (162)
A1: Variable Set [ Name:%CONVDATE To:%DATE Recurse Variables:Off Do Maths:Off Append:Off ]
A2: Flash [ Text:%CONVDATE Long:Off ]
A3: Variable Split [ Name:%CONVDATE Splitter:- Delete Base:Off ]
A4: Variable Set [ Name:%FDATE To:%CONVDATE2/%CONVDATE1/%CONVDATE3 Recurse Variables:Off Do Maths:Off Append:Off ]
A5: Flash [ Text:%FDATE Long:Off ]
Date Format (201)
A1: JavaScriptlet [ Code:var tdate = moment().format('DD-MM-YYYY'); Libraries:/storage/emulated/0/Tasker/Scripts/moment.js Auto Exit:On Timeout (Seconds):45 ]
A2: Flash [ Text:%tdate Long:Off ]
You can download momentjs for here: http://momentjs.com
is it possible to set the format in which %DATE is returned ?Ideally would need DD-MM-YY but using English language I get MM-D-YY ...
Run Shell [
Command:date +"date +%d-%m-%y"
Store Output In:%datestring
] Command:date +"%d-%m-%y" Dev5 (630)
A1: Variable Set [ Name:%par1 To:%TIMES Recurse Variables:Off Do Maths:Off
Append:Off ]
A2: Variable Set [ Name:%par2 To:dd-mm-yy
Recurse Variables:Off Do Maths:Off Append:Off ]
A3: Perform Task [ Name:getFormattedDate Priority:%priority Parameter 1
(%par1):%par1 Parameter 2 (%par2):%par2 Return Value Variable:%wrk Stop:Off ]
A4: Flash [ Text:%wrk Long:Off ]
getFormattedDate (189)
Run Both Together
A1: JavaScriptlet [ Code:var gsMonthNames = new Array(
'January',
'February',
'March',
'April',
'May',
'June',
'July',
'August',
'September',
'October',
'November',
'December'
);
var gsDayNames = new Array(
'Sunday',
'Monday',
'Tuesday',
'Wednesday',
'Thursday',
'Friday',
'Saturday'
);
var d = new Date(par[0] * 1000);
var f = par[1];
var formatteddate =
f.replace(/(yyyy|yy|mmmm|mmm|mm|dddd|ddd|dd|hh|nn|ss|a\/p)/gi,
function($1)
{
switch ($1)
{
case 'yyyy': return d.getFullYear();
case 'yy': return ('0' +
d.getFullYear()).slice(-2);
case 'mmmm': return
gsMonthNames[d.getMonth()];
case 'mmm': return
gsMonthNames[d.getMonth()].slice(0,3);
case 'mm': return ('0' +
(d.getMonth() + 1)).slice(-2);
case 'dddd': return
gsDayNames[d.getDay()];
case 'ddd': return
gsDayNames[d.getDay()].slice(0,3);
case 'dd': return ('0' +
d.getDate()).slice(-2);
case 'hh': return ('0' +
((h = d.getHours() % 12) ? h : 12)).slice(-2);
case 'HH': return ('0' +
d.getHours()).slice(-2);
case 'nn': return ('0' +
d.getMinutes()).slice(-2);
case 'ss': return ('0' +
d.getSeconds()).slice(-2);
case 'a/p': return
d.getHours() < 12 ? 'a' : 'p';
}
}
); Libraries:45 Auto Exit:On Timeout (Seconds):45 ]
A2: Return [ Value:%formatteddate Stop:On ]
… Thom
Can I change this in Android 7 (Nougat) ??