sql - 如何在 psql 中转换 unix_timestamp 整数?
问题描述
如何将 unix_timestamp 整数转换为可读文本中的时间。
如:
timestamp|integer|not null default 0
select timestamp from table limit 1;
1541001600
1541001600 应转换为Thu Nov 1 00:00:00 CST 2018
PostgreSQL 8.0.2
解决方案
您可以to_timestamp()
在 postgresql 中使用。
select to_timestamp(1541001600) AT TIME ZONE 'CST';
参考链接了解更多详情
对于 8.0:
SELECT TIMESTAMP WITH TIME ZONE 'epoch' + 1541001600 * INTERVAL '1 second';
推荐阅读
- angular - 在 Angular 和 ionic 中导入 javascript 库
- .htaccess - htacccess 重定向到单独的文件夹
- proof - 伊德里斯:证明一些矛盾的案例
- java - Appium IOS Native app 按标签查找元素
- php - 如果日期与我的会话日期匹配,我想插入函数调用
- c# - 如何使用 Sitecore Api 更改项目的模板 ID ..?? 注意 - 仅使用 sitecore api
- amazon-web-services - Auto Scaling 启动新实例时自动更新 Route 53
- tfs - 如何构建仅签入代码文件以及如何仅签入该构建的 tfs 中的代码工件?
- android - 找到具有最少字母的实例方法
- python - 使用 lambda 排序函数按每个元组组合值对字符串元组进行排序