mysql 时间戳与日期格式的相互转换
来源:互联网 发布:java方法调用范围 编辑:程序博客网 时间:2024/05/29 04:27
1、UNIX时间戳转换为日期用函数: FROM_UNIXTIME()
select FROM_UNIXTIME(1512397348);
输出:2017-12-04 22:22:28
2、日期转换为UNIX时间戳用函数: UNIX_TIMESTAMP()
Select UNIX_TIMESTAMP('2017-12-04 22:23:49');
输出:1512397429
Select UNIX_TIMESTAMP(NOW());
输出当前时间戳
例:mysql查询当天的记录数:
$sql=”select * from message Where DATE_FORMAT(FROM_UNIXTIME(chattime),’%Y-%m-%d’) = DATE_FORMAT(NOW(),’%Y-%m-%d’) order by id desc”;
PHP方式转换:
UNIX时间戳转换为日期用函数: date()
date('Y-m-d H:i:s', 1512397499);
日期转换为UNIX时间戳用函数:strtotime()
strtotime('2017-12-04 22:24:59');
原文地址:http://blog.csdn.net/u013372487/article/details/48131589
阅读全文
0 0
- mysql 时间戳与日期格式的相互转换
- mysql 时间戳与日期格式的相互转换
- mysql 时间戳与日期格式的相互转换
- mysql 时间戳与日期格式的相互转换
- mysql 时间戳与日期格式的相互转换
- mysql 时间戳与日期格式之间相互转换
- js时间戳与日期格式之间的相互转换
- mysql UNIX时间戳与日期的相互转换
- mysql UNIX时间戳与日期的相互转换
- mysql UNIX时间戳与日期的相互转换
- mysql UNIX时间戳与日期的相互转换
- mysql UNIX时间戳与日期的相互转换
- mysql UNIX时间戳与日期的相互转换
- mysql UNIX时间戳与日期的相互转换
- mysql UNIX时间戳与日期的相互转换
- mysql UNIX时间戳与日期的相互转换
- MySQL:UNIX时间戳与日期的相互转换
- mysql UNIX时间戳与日期的相互转换
- VS2013 如何创建应用程序图标
- cocos2DX-lua 点击事件封装
- 子进程会继承父进程用户id,用户组id,用户信息,文件描述符,数据段,堆栈,当前工作目录,创建文件权限,信号处理方式,进程组号,会话期号。
- 使用Spring框架的好处是什么?
- Causes for java.io.FileNotFoundException: class path resource [hibernat.xml] cannot be opened becaus
- mysql 时间戳与日期格式的相互转换
- 水仙花数。论求三位数中的各位数字。
- PSR-1规范
- 扩展欧几里德算法(待补充)
- 错误处理:"Could not load file or assembly 'Oracle.DataAccess' or one of its dependencies. An attempt was
- Echarts表格数据转换工具
- 204. Count Primes
- 什么是Spring的依赖注入?
- Linux下常用命令及快捷键