如何在Postgres中将日期时间转换为Unix纪元值? [英] How to convert date time into unix epoch value in Postgres?

查看:189
本文介绍了如何在Postgres中将日期时间转换为Unix纪元值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将以下格式转换为UNIX时间戳?

How do I convert the following format to UNIX timestamps?

一个值,如: 2015年1月2日10:20 应该转换为: 1418273999000

A value like: 01-02-2015 10:20 PM should be converted to: 1418273999000

我确实尝试过 to_timestamp 函数,但对我不起作用。

I did try to_timestamp function but its not working for me.

推荐答案

如果您的数据存储在名为ts的列中,在称为数据的表中,执行以下操作:

If your data is stored in a column called ts, in a table called data, do this:

select extract(epoch from ts) from data

这篇关于如何在Postgres中将日期时间转换为Unix纪元值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆