mysqlÖÐÄ¿½ñÈÕÆÚºÍʱ¼äµÄº¯Êý
mysql ÖлñÈ¡Ä¿½ñÈÕÆÚºÍʱ¼äµÄº¯Êý¹²ÓÐÈý¸ö£º1. now() º¯Êý£º·µ»ØÄ¿½ñÈÕÆÚºÍʱ¼ä£¬ÃûÌÃΪ ‘yyyy-mm-dd hh:mm:ss’£»2. curdate() º¯Êý£º·µ»ØÄ¿½ñÈÕÆÚ£¬ÃûÌÃΪ ‘yyyy-mm-dd’£»3. curtime() º¯Êý£º·µ»ØÄ¿½ñʱ¼ä£¬ÃûÌÃΪ ‘hh:mm:ss’¡£
MySQL ÖлñÈ¡Ä¿½ñÈÕÆÚºÍʱ¼äµÄº¯Êý
NOW() º¯Êý
NOW() º¯Êý·µ»ØÄ¿½ñÈÕÆÚºÍʱ¼ä£¬ÃûÌÃΪ ‘YYYY-MM-DD HH:MM:SS’¡£
Àý×Ó£º
SELECT NOW();
µÇ¼ºó¸´ÖÆ
Ч¹û£º
2023-03-08 14:32:31
µÇ¼ºó¸´ÖÆ
CURDATE() º¯Êý
CURDATE() º¯Êý·µ»ØÄ¿½ñÈÕÆÚ£¬ÃûÌÃΪ ‘YYYY-MM-DD’¡£
Àý×Ó£º
SELECT CURDATE();
µÇ¼ºó¸´ÖÆ
Ч¹û£º
2023-03-08
µÇ¼ºó¸´ÖÆ
CURTIME() º¯Êý
CURTIME() º¯Êý·µ»ØÄ¿½ñʱ¼ä£¬ÃûÌÃΪ ‘HH:MM:SS’¡£
Àý×Ó£º
SELECT CURTIME();
µÇ¼ºó¸´ÖÆ
Ч¹û£º
14:32:31
µÇ¼ºó¸´ÖÆ
ÆäËûÓ÷¨
³ýÁ˵¥¶ÀʹÓÃÕâЩº¯Êý£¬»¹¿ÉÒÔÓëÆäËûº¯ÊýÍŽáʹÓã¬ÀýÈ磺
DATE_ADD()£ºÌí¼ÓÖ¸¶¨ÌìÊý»òʱ¼äµ½Ä¿½ñÈÕÆÚ»òʱ¼ä¡£
DATE_SUB()£º´ÓÄ¿½ñÈÕÆÚ»òʱ¼äÖмõÈ¥Ö¸¶¨ÌìÊý»òʱ¼ä¡£
DATE_FORMAT()£º½«ÈÕÆÚ»òʱ¼äת»»Îª²î±ðµÄÃûÌá£
×¢ÖØ£º
ÕâЩº¯Êý·µ»ØЧÀÍÆ÷ÉϵÄÄ¿½ñÈÕÆÚºÍʱ¼ä£¬¶ø²»ÊÇ¿Í»§¶ËÅÌËã»úÉϵÄÈÕÆÚºÍʱ¼ä¡£
ÒÔÉϾÍÊÇmysqlÖÐÄ¿½ñÈÕÆÚºÍʱ¼äµÄº¯ÊýµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡