PHP 把秒数转为时分秒格式

PHP函数

1、gmdate

 

$seconds = 174940;
$hours = intval($seconds/3600);
$time1 = $hours."小时".gmdate('i分钟s秒', $seconds);
echo $time1;

2、gmstrftime

$seconds = 174940;
$hours = intval($seconds/3600);
$time1 = $hours.":".gmstrftime('%M:%S', $seconds);
echo $time1;

 

封装函数

$seconds = 174940;
$hour = floor($seconds/3600);
$minute = floor(($seconds-3600 * $hour)/60);
$second = floor((($seconds-3600 * $hour) - 60 * $minute) % 60);
$result = $hour.'小时'.$minute.'分钟'.$second.'秒';
echo $result;
(文章今日已有 1 人访问,总访问量 30 ::>_<::)
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇