Automate

Automate

Make your phone or tablet smarter with automation

Get it on Google Play

dateFormat

text dateFormat(timestamp, pattern, timeZone, language)

Returns the timestamp in timeZone, formatted according to pattern in language.

Predefined patterns:

  • "datetime" for the device default date & time format, the default
  • "date" for the device default date only format
  • "time" for the device default time only format
  • "iso8601" for "yyyy-MM-dd'T'HH:mm:ssZ"

Pattern symbols with special meaning:

SymbolComponentExamples
GEraAD
yYear2014
MMonthJuly; Jul; 07; 7
wWeek in year27
WWeek in month2
DDay in year189
dDay in month (1-31)10
EDay of weekTuesday; Tue; T
FDay of week in month (2nd Wed in July)2
HHour in day (0-23)0
kHour in day (1-24)24
KHour in am/pm (0-11)0
hHour in am/pm (1-12)12
aAm/pm markerPM
mMinute in hour30
sSecond in minute55
SMillisecond978
ZTime zone offset-0800
zTime zone namePacific Standard Time; PST; GMT-08:00
'Avoid interpretation'day' d
''Single quote''o'clock'

Examples

PatternResult
yyyy.MM.dd G 'at' HH:mm:ss z2001.07.04 AD at 12:08:56 PDT
EEE, MMM d, ''yyWed, Jul 4, '01
h:mm a12:08 PM
hh 'o''clock' a, zzzz12 o'clock PM, Pacific Daylight Time
K:mm a, z0:08 PM, PDT
yyyyy.MMMMM.dd GGG hh:mm aaa02001.July.04 AD 12:08 PM
EEE, d MMM yyyy HH:mm:ss ZWed, 4 Jul 2001 12:08:56 -0700
yyMMddHHmmssZ010704120856-0700
yyyy-MM-dd'T'HH:mm:ss.SSSZ2001-07-04T12:08:56.235-0700

Note! Use timeZone "UTC" when timestamp is a “time of day”, i.e. seconds since midnight, value.

Parameters

  1. timestampunix timestamp to format.
  2. pattern — optional formatting pattern, default is a date & time pattern for language.
  3. timeZone — optional time zone, defaults is current time zone.
  4. language — optional language code, defaults is the device language.

Returns

  • the formatted date and/or time.
Note! This documentation is also accessible within the app from Help & feedback menu.