mysql time_to_sec 函数介绍与使用方法
墨初 数据库 1018阅读
php 查询语句中的 time_to_sec 函数以当天开始时间00:00:00为基数,将当前时间中的时,分,秒转换为秒数并返回,但对输入的日期类型的数据不起作用。
php time_to_sec 函数详解
time_to_sec:以当天的开始时间为基准,将时间中的时,分,秒转为秒数!
语法:
SQL
TIME_TO_SEC(time)
参数:
参数 | 描述 |
---|---|
time | 必须,传入的时间或带有日期的时间 |
mysql time_to_sec 函数的使用
例:
SQL
mysql> select time_to_sec('17:05:01');
+-------------------------+
| time_to_sec('17:05:01') |
+-------------------------+
| 61501 |
+-------------------------+
1 row in set (0.00 sec)
mysql> select time_to_sec('2021/06/01 19:02:01');
+------------------------------------+
| time_to_sec('2021/06/01 19:02:01') |
+------------------------------------+
| 68521 |
+------------------------------------+
1 row in set (0.00 sec)
mysql> select time_to_sec(current_time); #73so.com
+---------------------------+
| time_to_sec(current_time) |
+---------------------------+
| 55463 |
+---------------------------+
1 row in set (0.00 sec)
手机预览赞赏支持
"作者已被打赏56次"
标签:mysql