drtppp75155 2012-06-11 09:19
浏览 32
已采纳

如何使用PHP gmdate函数将00:00:23转换为00:23 [关闭]

I have this code to show video duration in my app.

$duration = 23; // seconds
$duration = gmdate("H:i:s", $duration);

The above code outputs 00:00:23 but hours field is not required since it is just 23 seconds, I would like it to show 00:23 seconds, and if the video length is more than hour for example, it should show 01:24:19

Any idea?

Thanks

  • 写回答

3条回答 默认 最新

  • dongpao9437 2012-06-11 09:23
    关注

    Try this:

    $duration = gmdate($duration >= 3600 ? 'H:i:s' : 'i:s', $duration);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭