尊龙凯时人生就是搏

ThinkPHP5.1ÖÐÔõÑùʹÓÃʱ¼ä´¦Àíº¯Êý

Ò»¡¢Ê±¼ä´Áת»»ÎªÈÕÆÚʱ¼ä

ÔÚ PHP ÖУ¬UNIX ʱ¼ä´Á¿ÉÒÔ±»×ª»¯ÎªÈÕÆÚʱ¼ä×Ö·û´®£¬ÕâÊÇͨ¹ýŲÓà date() º¯ÊýʵÏֵġ£ÔÚ ThinkPHP5.1 ÖУ¬ÎÒÃÇ¿ÉÒÔʹÓà \think\helper\Str ÀàµÄ toDateTimeString() ÒªÁìÀ´½«Ê±¼ä´Áת»»ÎªÈÕÆÚʱ¼ä×Ö·û´®¡£

ÀýÈ磺

use think\helper\Str;

$time = 1573679399;
echo Str::toDateTimeString($time);
// Êä³ö: 2019-11-14 14:03:19

µÇ¼ºó¸´ÖÆ

¶þ¡¢ÈÕÆÚʱ¼äת»»ÎªÊ±¼ä´Á

Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»

ÔÚ PHP ÖУ¬ÎÒÃÇ¿ÉÒÔʹÓà strtotime() º¯Êý½«ÈÕÆÚʱ¼ä×Ö·û´®×ª»»Îª UNIX ʱ¼ä´Á¡£ÔÚ ThinkPHP5.1 ÖУ¬ÎÒÃÇ¿ÉÒÔʹÓà \think\helper\Str ÀàµÄ unixTime() ÒªÁìÀ´½«ÈÕÆÚʱ¼ä×Ö·û´®×ª»»ÎªÊ±¼ä´Á¡£

ÀýÈ磺

use think\helper\Str;

$datetime = '2019-11-14 14:03:19';
echo Str::unixTime($datetime);
// Êä³ö: 1573679399

µÇ¼ºó¸´ÖÆ

Èý¡¢Ê±¼äÃûÌû¯

ÔÚ PHP ÖУ¬ÎÒÃÇ¿ÉÒÔʹÓà date() º¯Êý¶ÔÈÕÆÚʱ¼ä×Ö·û´®¾ÙÐÐÃûÌû¯¡£ÔÚ ThinkPHP5.1 ÖУ¬ÎÒÃÇ¿ÉÒÔʹÓà \think\helper\Str ÀàµÄ dateFormat() ÒªÁì¶ÔÈÕÆÚʱ¼ä×Ö·û´®¾ÙÐÐÃûÌû¯¡£

ÀýÈ磺

use think\helper\Str;

$datetime = '2019-11-14 14:03:19';
echo Str::dateFormat($datetime, 'YÄêmÔÂdÈÕ H:i:s');
// Êä³ö: 2019Äê11ÔÂ14ÈÕ 14:03:19

µÇ¼ºó¸´ÖÆ

ÔÚ dateFormat() ÒªÁìÖУ¬µÚÒ»¸ö²ÎÊýÊÇÐèÒªÃûÌû¯µÄÈÕÆÚʱ¼ä×Ö·û´®£¬µÚ¶þ¸ö²ÎÊýÊÇÃûÌû¯×Ö·û´®¡£³£ÓõÄÃûÌû¯×Ö·û´®ÈçÏ£º

ÈÕÆÚÃûÌÃ×Ö·û ˵Ã÷
Y Äê·Ý£¨4 λÊý£©
m Ô·ݣ¨01-12£©
d ÈÕÆÚ£¨01-31£©
H Сʱ£¨00-23£©
i ·ÖÖÓ£¨00-59£©
s ÃëÖÓ£¨00-59£©

ËÄ¡¢Ê±¼ä²îÅÌËã

ÔÚ PHP ÖУ¬ÎÒÃÇ¿ÉÒÔʹÓà strtotime() º¯ÊýÅÌËãÁ½¸öÈÕÆÚʱ¼äÖ®¼äµÄʱ¼ä²î¡£ÔÚ ThinkPHP5.1 ÖУ¬ÎÒÃÇ¿ÉÒÔʹÓà \think\helper\Str ÀàµÄ time() ÒªÁìÅÌËãÁ½¸öÈÕÆÚʱ¼äÖ®¼äµÄʱ¼ä²î¡£

ÀýÈ磺

use think\helper\Str;

$start = '2019-11-14 14:03:19';
$end = '2019-11-15 16:05:12';

$diff = Str::time($start, $end);

echo $diff->format('%a Ìì %h Сʱ %i ·ÖÖÓ %s Ãë');
// Êä³ö: 1 Ìì 2 Сʱ 1 ·ÖÖÓ 53 Ãë

µÇ¼ºó¸´ÖÆ

ÔÚ time() ÒªÁìÖУ¬µÚÒ»¸ö²ÎÊýÊÇ×îÏÈʱ¼ä£¬µÚ¶þ¸ö²ÎÊýÊÇ¿¢ÊÂʱ¼ä¡£ÈôÊÇÒªÅÌËãÁ½¸öʱ¼äÖ®¼äµÄÌìÊý¡¢Ð¡Ê±Êý¡¢·ÖÖÓÊý¡¢ÃëÊýµÈµÈ£¬¿ÉÒÔʹÓà DateTime ¹¤¾ßµÄ format() ÒªÁì¡£

ÒÔÉϾÍÊÇThinkPHP5.1ÖÐÔõÑùʹÓÃʱ¼ä´¦Àíº¯ÊýµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是搏

18523999891

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

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

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