Contents
to_timestamp()
A function for converting a timestamp string into the TIMESTAMPTZ datatype
to_timestamp()
is a system function for converting the string representation of a timestamp into the TIMESTAMP WITH TIME ZONE
datatype using the specified format.
to_timestamp()
was added in PostgreSQL 7.0.
Usage
to_timestamp (text
,text
) →timestamp with time zone
to_timestamp()
converts the provided string into a TIMESTAMP WITH TIME ZONE
value using the specified format; see the PostgreSQL documentation section Template Patterns for Date/Time Formatting for details.
Note there is no equivalent function for converting a string into a plain TIMESTAMP
data type.
Change history
- PostgreSQL 11
TZH
andTZM
format patterns added for specifying the time zone's offset fromUTC
in hours and minutes (commit 11b623dd)
- PostgreSQL 10
- input field range checking tightened up (commit d3cd36a1)
- PostgreSQL 7.0
- added (commit b866d2e2)
References
- PostgreSQL documentation: Formatting Functions
- PostgreSQL documentation: Template Patterns for Date/Time Formatting