MYSQL »ñÈ¡µ±Ç°ÈÕÆÚ¼°ÈÕÆÚ¸ñʽ
»ñȡϵͳÈÕÆÚ£º NOW()
¸ñʽ»¯ÈÕÆÚ£º DATE_FORMAT(date, format)
×¢£º date£ºÊ±¼ä×Ö¶Î
format£ºÈÕÆÚ¸ñʽ
·µ»ØϵͳÈÕÆÚ,Êä³ö 2009-12-25 14:38:59
select now();
Êä³ö 09-12-25
select date_format(now(),'%y-%m-%d');
¸ù¾Ýformat×Ö·û´®¸ñʽ»¯dateÖµ:
%S, %s Á½Î»Êý×ÖÐÎʽµÄÃ루 00,01, ..., 59£©
%I, %i Á½Î»Êý×ÖÐÎʽµÄ·Ö£¨ 00,01, ..., 59£©
%H Á½Î»Êý×ÖÐÎʽµÄСʱ£¬24 Сʱ£¨00,01, ..., 23£©
%h Á½Î»Êý×ÖÐÎʽµÄСʱ£¬12 Сʱ£¨01,02, ..., 12£©
%k Êý×ÖÐÎʽµÄСʱ£¬24 Сʱ£¨0,1, ..., 23£©
%l Êý×ÖÐÎʽµÄСʱ£¬12 Сʱ£¨1, 2, ..., 12£©
%T 24 СʱµÄʱ¼äÐÎʽ£¨hh:mm:ss£©
%r 12 СʱµÄʱ¼äÐÎʽ£¨hh:mm:ss AM »òhh:mm:ss PM£©
%p AM»òPM
%W Ò»ÖÜÖÐÿһÌìµÄÃû³Æ£¨Sunday, Monday, ..., Saturday£©
%a Ò»ÖÜÖÐÿһÌìÃû³ÆµÄËõд£¨Sun, Mon, ..., Sat£©
%d Á½Î»Êý×Ö±íʾÔÂÖеÄÌìÊý£¨00, 01,..., 31£©
%e Êý×ÖÐÎʽ±íʾÔÂÖеÄÌìÊý£¨1, 2£¬ ..., 31£©
%D Ó¢Îĺó׺±íʾÔÂÖеÄÌìÊý£¨1st, 2nd, 3rd,...£©
%w ÒÔÊý×ÖÐÎʽ±íʾÖÜÖеÄÌìÊý£¨ 0 = Sunday, 1=Monday, ..., 6=Saturday£©
%j ÒÔÈýλÊý×Ö±íʾÄêÖеÄÌìÊý£¨ 001, 002, ..., 366£©
%U ÖÜ£¨0, 1, 52£©£¬ÆäÖÐSunday ΪÖÜÖеĵÚÒ»Ìì
%u ÖÜ£¨0, 1, 52£©£¬ÆäÖÐMonday ΪÖÜÖеĵÚÒ»Ìì
%M ÔÂÃû£¨January, February, ..., December£©
%b ËõдµÄÔÂÃû£¨ January, February,...., December£©
%m Á½Î»Êý×Ö±íʾµÄÔ·ݣ¨01, 02, ..., 12£©
%c Êý×Ö±íʾµÄÔ·ݣ¨1, 2, ...., 12£©
%Y ËÄλÊý×Ö±íʾµÄÄê·Ý
%y Á½Î»Êý×Ö±íʾµÄÄê·Ý
%% Ö±½ÓÖµ“%”