×ðÁú¿­Ê±

laravel ×Ö·û´®×ªÈÕÆÚ

ÔÚlaravelÖУ¬ÓÐʱÐèÒª½«×Ö·û´®×ª»»ÎªÈÕÆÚÃûÌÃÒÔ±ãÓÚ¾ÙÐÐÈÕÆÚ²Ù×÷ºÍÅÌËã¡£laravelÌṩÁ˶àÖÖÒªÁìÀ´ÊµÏÖ×Ö·û´®×ªÈÕÆÚ²Ù×÷£¬±¾ÎĽ«¶ÔÆäÖеļ¸ÖÖÒªÁì¾ÙÐÐÏÈÈÝ¡£

CarbonÀà

CarbonÊÇÒ»¸öPHPÀ©Õ¹°ü£¬ÌṩÈÕÆÚºÍʱ¼äµÄ¼òÆÓ²Ù×÷·½·¨¡£laravelÖÐĬÈϼ¯³ÉÁËCarbonÀ࣬²¢ÌṩÁËCarbonʵÀý»¯µÄ±ã½ÝÒªÁì¡£

ʹÓÃCarbonÀཫ×Ö·û´®×ª»»ÎªÈÕÆÚµÄÒªÁìÈçÏ£º

$date = CarbonCarbon::createFromFormat('Y-m-d', '2022-06-20');
echo $date->format('Y-m-d H:i:s'); // 2022-06-20 00:00:00

µÇ¼ºó¸´ÖÆ

ÔÚÕâ¸öÀý×ÓÖУ¬ÎÒÃÇʹÓÃcreateFromFormatÒªÁ콫×Ö·û´®×ª»»ÎªÈÕÆÚ£¬²¢×ª´ïÁ˲ÎÊý¡®Y-m-d¡¯À´Åú×¢ÕâÊÇÒ»¸öÄê-ÔÂ-ÈÕÃûÌõÄ×Ö·û´®¡£ÔÚת»»ºó£¬ÎÒÃÇ¿ÉÒÔʹÓÃformatÒªÁ콫ÈÕÆÚÃûÌû¯ÎªÎÒÃÇÐèÒªµÄÃûÌã¬ÕâÀïÎÒÃÇÊä³öµÄÃûÌÃÊÇÄê-ÔÂ-ÈÕʱ:·Ö:Ãë¡£

strtotimeº¯Êý

strtotimeº¯ÊýÊÇPHPµÄÒ»¸öÄÚÖú¯Êý£¬¿ÉÒÔ½«×Ö·û´®×ª»»ÎªÊ±¼ä´Á¡£ÎÒÃÇ¿ÉÒÔʹÓÃÕâ¸öʱ¼ä´ÁÀ´½øÒ»²½²Ù×÷ÈÕÆÚ¡£

ʹÓÃstrtotimeº¯Êý½«×Ö·û´®×ª»»ÎªÈÕÆÚµÄÒªÁìÈçÏ£º

$date = date('Y-m-d', strtotime('2022-06-20'));
echo $date; // 2022-06-20

µÇ¼ºó¸´ÖÆ

ÔÚÕâ¸öÀý×ÓÖУ¬ÎÒÃÇʹÓÃstrtotimeº¯Êý½«×Ö·û´®¡®2022-06-20¡¯×ª»»ÎªÊ±¼ä´Á£¬²¢½«Æäת´ï¸ødateº¯ÊýÒÔÊä³öÎÒÃÇÐèÒªµÄÃûÌá£

ÐèҪעÖصÄÊÇ£¬strtotimeº¯Êý½öÊÊÓÃÓÚһЩÌØÊâÃûÌã¬ÈçYYYY-MM-DDÃûÌõÄÈÕÆÚ×Ö·û´®£¬¶ø¹ØÓÚÆäËûÃûÌõÄÈÕÆÚ×Ö·û´®£¬ÎÒÃÇ»¹ÐèҪʹÓÃcreateFromFormatÒªÁì»ò×ÔÐбàдÆÊÎöº¯Êý¡£

CarbonÖÐÎÄ

CarbonÖÐÎÄÊǶÔCarbonÀàµÄÖÐÎÄÀ©Õ¹£¬Ö§³ÖʹÓÃÖÐÎıí´ïʽÌåÏÖÈÕÆÚºÍʱ¼ä¡£Õâ¹ØÓÚһЩÖÐÎÄ»¯µÄÏîÄ¿À´ËµºÜÊÇÀû±ã¡£

ʹÓÃCarbonÖÐÎĽ«×Ö·û´®×ª»»ÎªÈÕÆÚµÄÒªÁìÈçÏ£º

$date = CarbonChineseCarbonChinese::parse('2022Äê06ÔÂ20ÈÕ');
echo $date->format('Y-m-d H:i:s'); // 2022-06-20 00:00:00

µÇ¼ºó¸´ÖÆ

ÔÚÕâ¸öÀý×ÓÖУ¬ÎÒÃÇʹÓÃCarbonChineseÀàµÄparseÒªÁ콫ÖÐÎÄÈÕÆÚ×Ö·û´®¡®2022Äê06ÔÂ20ÈÕ¡¯×ª»»ÎªÈÕÆÚ£¬²¢Ê¹ÓÃformatÒªÁìÊä³öÎÒÃÇÐèÒªµÄÃûÌá£

ÐèҪעÖصÄÊÇ£¬CarbonChinese°üÊÇÒ»¸öµÚÈý·½À©Õ¹°ü£¬ÐèÒªÔÚÏîÄ¿ÖоÙÐÐ×°Öá£

×ܽá

ÔÚlaravelÖУ¬½«×Ö·û´®×ª»»ÎªÈÕÆÚÓжàÖÖÒªÁì¿ÉÑ¡Ôñ£¬¿ÉÒÔƾ֤ÏîÄ¿ÐèÇóÑ¡Ôñ²î±ðµÄÒªÁ졣ʹÓÃCarbonÀà½ÏÁ¿±ã½Ý£¬²»¹ý¹ØÓÚһЩÌØÊâÃûÌõÄÈÕÆÚ×Ö·û´®£¬½¨ÒéʹÓÃcreateFromFormatÒªÁ죻ʹÓÃstrtotimeº¯ÊýÊÊÓÃÓÚһЩÄÚÖÃÃûÌõÄÈÕÆÚ×Ö·û´®£»Ê¹ÓÃCarbonÖÐÎÄÊÊÓÃÓÚÖÐÎÄ»¯µÄÏîÄ¿¡£

ÒÔÉϾÍÊÇlaravel ×Ö·û´®×ªÈÕÆÚµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿­Ê±ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿­Ê±ÊµÊ±ÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎ壬9:30-18:30£¬½ÚãåÈÕÐÝÏ¢

QR code
¡¾ÍøÕ¾µØͼ¡¿¡¾sitemap¡¿