php 中的 time_to_sec 函数可以以当天00:00:00为基数,将当前的时间的时,分,秒转换为秒数,对日期不会起作用。
php time_to_sec 函数详解
time_to_sec:将指定时间转换为秒!
语法:
TIME_TO_SEC(time)
参数:
time:传入时间,如果传入了日期部分,会自动忽略,只是将时间部分转换成秒
注意:这里是指将传入的时间转换成距离当天00:00:00的秒数,00:00:00为基数,等于 0 秒
mysql time_to_sec 使用示例
示例代码:
select time_to_sec('19:02:01'); select time_to_sec('2021/06/01 19:02:01'); select time_to_sec(current_time);