教程集 www.jiaochengji.com
教程集 >  数据库  >  mysql  >  正文 mysql获取当前系统时间及当前日期方便查询判定

mysql获取当前系统时间及当前日期方便查询判定

发布时间:2015-11-08   编辑:jiaochengji.com
需要判定结束日期是不是大于当前日期,一般情况下都是通过php判定日期,然后查询。得到判定日期的sql查询语句的php代码:

需要判定结束日期是不是大于当前日期,一般情况下都是通过php判定日期,然后查询。
得到判定日期的sql查询语句的php代码:
 

复制代码 代码如下:
$now = time(); //获取当期的日期
$sql="select * from `team` where end_time>$now ORDER BY sort_order limit 0,4";

下面为大家介绍使用MySql时间函数获取当前时间的方法,在日常的开发中这个函数很有用哦。
 

复制代码 代码如下:

mysql> select current_timestamp();
+---------------------+
| current_timestamp() |
+---------------------+
| 2010-01-18 21:24:37 |
+---------------------+
1 row in set (0.00 sec)

mysql> select current_date();
+----------------+
| current_date() |
+----------------+
| 2010-01-18 |
+----------------+
1 row in set (0.00 sec)

mysql> select current_time();
+----------------+
| current_time() |
+----------------+
| 21:24:46 |
+----------------+
1 row in set (0.00 sec)

您可能感兴趣的文章:
mysql获取当前系统时间及当前日期方便查询判定
mysql获取系统当前时间的实例学习
mysql优化之如何定位效率较低的SQL
mysql获取系统当前时间的简单例子
mysql innodb数据库引擎解析
js获取当前系统时间实例代码
mysql优化之定位效率较低的SQL
mysql 时间段查询语句大全
关于mysql日期的一些例子
如何开启mysql和php慢日志

[关闭]
~ ~