hi,欢迎访问本站!
当前位置: 首页数据库正文

mysql time_to_sec 函数介绍与使用方法

墨初 数据库 568阅读

php 查询语句中的 time_to_sec 函数以当天开始时间00:00:00为基数,将当前时间中的时,分,秒转换为秒数并返回,但对输入的日期类型的数据不起作用。

php time_to_sec 函数详解

time_to_sec:以当天的开始时间为基准,将时间中的时,分,秒转为秒数!

语法:

TIME_TO_SEC(time)

参数:

参数描述
time必须,传入的时间或带有日期的时间

mysql time_to_sec 函数的使用

例:

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)
标签:
声明:无特别说明,转载请标明本文来源!