mysqlÖÐnowµÄÓ÷¨
now() º¯ÊýÊÇ mysql ÖÐÒ»¸öʱ¼ä´Áº¯Êý£¬·µ»ØÄ¿½ñϵͳʱ¼äºÍÈÕÆÚ¡£ÆäÓ÷¨Îª now([format])£¬ÆäÖÐ format ָ׼ʱ¼äÃûÌã¬Ä¬ÒÔΪ yyyy-mm-dd hh:mm:ss¡£·µ»ØµÄʱ¼ä¿ÉÖ¸¶¨Îª iso 8601 ÃûÌá¢ÈÕÆÚÃûÌûòʱ¼äÃûÌá£now() º¯Êý·µ»ØЧÀÍÆ÷ʱ¼ä£¬¾«¶ÈÊÜЧÀÍÆ÷ʱÖÓÇø·ÖÂÊÓ°Ï죬ÔÚ½ÏÁ¿Ê±¼ä´ÁʱӦÉóÉ÷ʹÓá£
MySQL ÖÐ NOW() º¯ÊýÏê½â
ʲôÊÇ NOW() º¯Êý£¿
NOW() º¯ÊýÊÇÒ»¸ö MySQL º¯Êý£¬ÓÃÓÚ·µ»ØÄ¿½ñϵͳʱ¼äºÍÈÕÆÚ¡£
NOW() º¯ÊýµÄÓ÷¨
NOW() º¯Êý¿ÉÒÔƾ֤ÒÔÏÂÓ﷨ʹÓãº
NOW([format])
µÇ¼ºó¸´ÖÆ
ÆäÖУº
format£¨¿ÉÑ¡£©£ºÖ¸×¼Ê±¼äÃûÌá£ÈôÊÇûÓÐÖ¸ÃüÃûÌã¬Ôò·µ»Ø YYYY-MM-DD HH:MM:SS ÃûÌõÄʱ¼ä´Á¡£
Ïêϸ˵Ã÷
NOW() º¯Êý·µ»ØÄ¿½ñʱ¼ä£¬¸Ãʱ¼ä»ùÓÚЧÀÍÆ÷µÄÖ÷»úÅÌËã»úʱÖÓ¡£ËüÊÇÒ»¸öÒ×ʧº¯Êý£¬ÕâÒâζ×Åÿ´ÎŲÓÃËüʱ¶¼»á·µ»ØÒ»¸öеÄÖµ¡£
ÈÕÆÚÃûÌÃ
NOW() º¯Êý·µ»ØµÄʱ¼äÃûÌÿÉÒÔÖ¸¶¨ÎªÒÔÏÂÖµÖ®Ò»£º
%Y-%m-%d %H:%M:%S£ºISO 8601 ÃûÌÃ
%Y-%m-%d£ºÈÕÆÚÃûÌÃ
%H:%M:%S£ºÊ±¼äÃûÌÃ
ÈôÊÇδָ¶¨ÈÕÆÚÃûÌã¬NOW() º¯Êý½«·µ»Ø YYYY-MM-DD HH:MM:SS ÃûÌõÄÖµ¡£
ʾÀý
SELECT NOW();
µÇ¼ºó¸´ÖÆ
Êä³ö£º
2023-03-08 14:30:01
µÇ¼ºó¸´ÖÆ
SELECT NOW('%Y-%m-%d');
µÇ¼ºó¸´ÖÆ
Êä³ö£º
2023-03-08
µÇ¼ºó¸´ÖÆ
×¢ÖØÊÂÏî
NOW() º¯Êý·µ»ØЧÀÍÆ÷ʱ¼ä£¬¶ø²»ÊÇ¿Í»§¶Ëʱ¼ä¡£
NOW() º¯ÊýµÄ¾«¶ÈÈ¡¾öÓÚЧÀÍÆ÷ʱÖÓµÄÇø·ÖÂÊ¡£
ÓÉÓÚ NOW() º¯ÊýÊÇÒ×ʧµÄ£¬Òò´ËÔÚ½ÏÁ¿Ê±¼ä´ÁʱӦÉóÉ÷ʹÓá£
ÒÔÉϾÍÊÇmysqlÖÐnowµÄÓ÷¨µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡