Follow

DATETIME - formating dates & times in published content

Formats the output of a given time stamp and/or converts it into a different time zone.

The parameters are DATETIME(timestamp, format, output timezone)

  • timestamp = input; required, uses the format “yyyy-mm-dd hh:mm:ss”
  • format = output format, e.g. ‘HH:mm:ss’ (see details)
  • output timezone = timezone for output; optional, defaults to project’s time zone (currently defaults to project owner’s time zone)

Use cases….

The content body (e.g. an outgoing sms) might look like:

"You started at |datetime(audience.start_time, “HH:mm:ss”, “America/New_York”)| and finished at |datetime(audience.end_time, “HH:mm:ss”, “America/New_York”)|."

The example above shows the full-blown version with all the optional function parameters. The short one would look like: 

"You started at |datetime(audience.start_time)| and finished at |datetime(audience.end_time)|."

The second function parameter specifies the date/time format, and the 3rd one specifies the time zone to use. The time zone can be specified in 2 formats - 'America/New_York' (this is a universally-accepted representation for US Eastern Time).

Other examples are

|datetime(audience.end_time, “HH:mm:ss Z (ZZ)”, audience.timezone)|
Example result: “04:05:00 PST (-0800)”

|datetime(audience.end_time, “d/M/yyyy, ZZ, HH:mm:ss”, audience.timezone)|
Example result: “1/1/2015, -0800, 04:05:00”

 

|datetime(audience.end_time, “HH:mm:ss Z (ZZ)”, audience.timezone)|
Let’s say the audience.end_time is “2015-06-01 12:05:00” instead of “2015-01-01 12:05:00”
Example result: “05:05:00 PDT (-0700)”

Below are the date-time formatting specifications.

Format

Description

W

number of the week in the year (Monday is the first day of the week) with leading zero, 00-53

w

number of the week in the year (Sunday is the first day of the week) with leading zero, 00-53

yy or YY

2-digit year, e.g. 16

yyyy or YYYY

4-digit year, e.g. 2016

M

number of the month without leading zero, e.g. 1

MM

number of the month with leading zero, e.g. 01

MMM

abbreviated month name, e.g. Jan

MMMM

full month name, e.g. January

d or D

day of the month without leading zero, e.g. 1

dd or DD

day of the month with leading zero, e.g. 01

ddd

abbreviated name of the day of the week, e.g. Sun

dddd

full name of the day of the week, e.g. Sunday

h

hours (12-hr format) without leading zero

hh

hours (12-hr format) with leading zero

H

hours (24-hr format) without leading zero

HH

hours (24-hr format) with leading zero

mm

minutes

ss

seconds

SSSSSS

microseconds with leading zeros, 000000-999999

p or tt

AM/PM label

z or Z or TZD

time zone label, e.g. UTC

zz or ZZ

time zone offset without colon, e.g. +0100

zzz or ZZZ

time zone offset with colon, e.g. +01:00

 

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments