Skip to content
Reference > Methods

datePart(unixEpochMillis,part,timezone)

Definition

Long datePart(Number unixEpochMillis, String part, String timezone)

Description

Returns part of a date based on some supplied time in milliseconds since the Unix epoch (1/1/1970) in the given timezone. Returns a Long in milliseconds of the part of the date of interest.

Parameter Definition

Name Type Description
unixEpochMillis Number Number of milliseconds since 1/1/1970 in UTC timezone
part String Date fields to return:
  • "y"-year
  • "M"-month
  • "d"-day
  • "H"-hour
  • "m"-minute
  • "s"-Second
  • "S"-millisecond
timezone String Timezone to return extracted fields in

Examples

Long r1 = datePart(1000000000,"y","EST5EDT"); // r1 == 18000000
Long r2 = datePart(1000000000,"HmsS","UTC"); // r2 == 49600000