getFormattedDate

This task is intended to be used with the Perform Task action, allowing you to provide a time (seconds) and a format string. Specific character sequences in the format string will be replaced with appropriate text based on the date provided. A few examples may help explain things;

Example 1

Let's say you want to flash the current date in the format Friday, March 01, 2013. To do so you would use the following action to place the formatted date into the %mydate variable:

Perform Task [ Name:getFormattedDate Stop:Off Priority:10 Parameter 1 (%par1):%TIMES Parameter 2 (%par2):dddd, mmmm dd, yyyy Return Value Variable:%mydate ]

Example 2

Let's say you want to save a file with a name based on the current date, and you want the name to be the 4-digit year, followed by the 2-digit month, followed by the 2-digit day. To place this file name in the %filename variable, you would used the following action:

Perform Task [ Name:getFormattedDate Stop:Off Priority:10 Parameter 1 (%par1):%TIMES Parameter 2 (%par2):yyyymmdd Return Value Variable:%filename ]

Format string substitutions

Character sequences in the format string will be replaced as follows:

Character Sequence Substituted Value
yyyy 4-digit year
yy 2-digit year
mmmm full month name (i.e. January, February, etc.)
mmm 3-character month name (i.e. Jan, Feb, etc.)
mm 2-digit month number
dddd full day name (i.e. Sunday, Monday, etc.)
ddd 3-character day name (i.e. Sun, Mon, etc.)
dd 2-digit day of month
hh 2-digit hour (12 hours)
HH 2-digit hour (24 hours)
nn 2-digit minute
ss 2-digit second
a/p a or p (for before noon, and noon or later)

Download

Download this Tasker Task

Enjoy

- UncleMike

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License