to_timestamp() 是一个系统函数,用于使用指定格式将时间戳的字符串表示形式转换为 TIMESTAMP WITH TIME ZONE 数据类型。
to_timestamp() 函数添加于 PostgreSQL 7.0。
用法
to_timestamp (text,text) →timestamp with time zone
to_timestamp() 使用指定的格式将提供的字符串转换为 TIMESTAMP WITH TIME ZONE 值;有关详细信息,请参阅 PostgreSQL 文档的 日期/时间格式的模板模式 部分。
请注意,没有等效函数可以将字符串转换为普通的 TIMESTAMP 数据类型。
变更历史
- PostgreSQL 11
- 添加了
TZH和TZM格式模式,用于指定时区相对于UTC的小时和分钟偏移量(提交 11b623dd)
- 添加了
- PostgreSQL 10
- 输入字段范围检查已收紧(提交 d3cd36a1)
- PostgreSQL 7.0
- 已添加(提交 b866d2e2)
参考资料
- PostgreSQL documentation: Formatting Functions
- PostgreSQL documentation: Template Patterns for Date/Time Formatting
