mysql 中 unix_timestamp和from_unixtime 时间戳函数
2015-11-12 11:11
435 查看
1.unix_timestamp
将时间转化为时间戳。(date 类型数据转换成 timestamp 形式整数)
没传时间参数则取当前时间的时间戳
eg:select unix_timestamp(); 得到 1447297633
select
unix_timestamp('2015-11-11'); 得到 1447171200
2、from_unixtime
, 也可以指定格式 from_unixtime(1355272360,'%Y-%m-%d') |
(将timestamp
形式整数 转化为 date类型)
eg:selectfrom_unixtime(1447297633);
或者select
from_unixtime(1447297633,"%Y-%m-%d"); 得到 2015-11-12
将时间转化为时间戳。(date 类型数据转换成 timestamp 形式整数)
没传时间参数则取当前时间的时间戳
eg:select unix_timestamp(); 得到 1447297633
select
unix_timestamp('2015-11-11'); 得到 1447171200
2、from_unixtime
, 也可以指定格式 from_unixtime(1355272360,'%Y-%m-%d') |
(将timestamp
形式整数 转化为 date类型)
eg:selectfrom_unixtime(1447297633);
或者select
from_unixtime(1447297633,"%Y-%m-%d"); 得到 2015-11-12
相关文章推荐
- ubuntu14下mysql忘记密码的处理
- ubuntu14下mysql忘记密码的处理
- mysql基础教程(2)---存储过程
- mysql 分页的高效实现
- mysql中添加一个和root一样的用户用于远程连接
- 开源IDS系列--解决barnyard2 停止运行 libmysqlclient.so.16.0.0
- 【转载】LVS+MYCAT+读写分离+MYSQL主备同步部署手册(邢锋)
- MySql 如何实现不同数据库同步【2个】
- mysql using()用法
- 《Mysql技术内幕》札记(下)
- 换IP后MySQL报错:not allowed to connect to this MySQL server
- Mysql数据库非3306端口命令连接数据库解决方法
- Mysql修复损坏表并写脚本自动修复
- mysql基础教程(1)---视图
- MySql技巧个人笔记
- MyBatis+MySql Insert操作失败解决办法
- 报表开发工具中mysql数据库连接编码转化失效解决方案
- 转载:windows的mysql提权方式
- mysql 小记 增删改 从文件读取到表中 修改远程登录用户 更改ocs用户密码
- 玩转mysql(入门级练习)