You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Make.com中将秒转为HH:MM格式时补零异常问题求助

解决Make.com中秒数转HH:MM格式的补零问题

问题场景

通过Make.com的Webhook向WordPress发送JSON时,需将86400秒以内的秒数转换为HH:MM格式,但现有代码在分钟为单数位(如0)时会输出18:0,而非预期的18:00,非整分场景(如12:35)显示正常。

当前使用的Make.com代码:

{{floor(1.seconds / 3600)}}:{{floor((1.seconds % 3600) / 60)}}:{{((1.seconds % 3600) % 60)}}

解决方案

利用Make.com的formatNumber函数,给计算出的小时、分钟强制设置两位数格式,不足两位时自动补零。

仅HH:MM格式(匹配需求)

{{formatNumber(floor(1.seconds / 3600), "00")}}:{{formatNumber(floor((1.seconds % 3600) / 60), "00")}}

若需扩展为HH:MM:SS格式

{{formatNumber(floor(1.seconds / 3600), "00")}}:{{formatNumber(floor((1.seconds % 3600) / 60), "00")}}:{{formatNumber((1.seconds % 3600) % 60, "00")}}

说明

  • formatNumber(value, "00")会将数值格式化为两位数字,当数值小于10时自动前置补零
  • floor函数用于确保得到整数的小时、分钟/秒数,避免小数干扰格式

内容的提问来源于stack exchange,提问作者ValentinoMaciej

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.13 18:13:19