首页
归档
笔记
树洞
搜索
友言

文章详情

Interesting People Record Interesting.

/ PHP / 文章详情

通过时间戳获取天、时、分钟

Sonder
2019-08-29
439字
1分钟
浏览 (2.5k)

复制代码
/**
 * str_pad 补零
 * @return array
 */
function setTime($sec){
    $_seconds = intval($sec);
    $seconds = str_pad($_seconds%60,2,'0',STR_PAD_LEFT);
    $_mins = intval($_seconds/60);
    $_hours = intval($_mins/60);
    $hours = str_pad($_hours%24,2,'0',STR_PAD_LEFT);
    $day = str_pad(intval($_hours/24),2,'0',STR_PAD_LEFT);
    $mins = str_pad($_mins%60,2,'0',STR_PAD_LEFT);
    return [$day,$hours,$mins,$seconds];
}
下一篇 / 生成微信红包金额

🎯 相关文章

💡 推荐文章

🕵️‍♂️ 评论 (0)