datetime.parse

This function parses the given datetime to the DateTime with time zone, default base on UTC. The timezone follows the IANA timezone.

Syntax

datetime.parse(str, UTC)

Arguments

Argument

Type

Description

str

any

Date and time with time zone.

timezone

string

The timezone in which the string needs to be parsed.

The default is UTC.

Returns

Type

Description

datetime

Datetime converted to the specified timezone.

Examples

The function datetime.parse("2020-03-19T15:02:03+06:00", "America/Los_Angeles") returns 2020-03-19T02:02:03-07:00.