使用此插件

formatTime 函数使用以下参数:

  • ns(必需,整数):要转换或格式化的秒数

  • tf(可选,字符串):要返回秒的格式类型;默认为秒

    • 如果您希望以天为单位显示时间,则可将其设置为 "d"(默认情况下,舍入到以 1/4 天为基准所得出的最近值)
    • 如果您希望以小时为单位显示时间,则可将其设置为 "h"(默认情况下,舍入到以 1/4 小时为基准所得出的最近值)
    • 如果您希望以分钟为单位显示时间,则可将其设置为 "m"(默认情况下,舍入到以 1/2 分钟为基准所得出的最近值)
    • 如果您希望以秒为单位显示时间,则可将其设置为 "s"(默认情况下,舍入到以 5 秒为基准所得出的最近值)
  • bml(可选,数字):舍入基准的长度。 默认为 tf 参数中列出的基准值

此函数将返回使用 tf 参数中指定的单位进行格式化的秒数。 如果未设置 tf 参数:

  • 任何小于 1 分钟的值都会以最接近的 5 秒基准进行四舍五入
  • 任何介于 1 分钟和 1 小时之间的值都会以最接近的 1/2 分钟基准进行四舍五入
  • 若时间介于 1 小时和 1 天之间,则将以“0.25 小时”为基准四舍五入到最接近的值
  • 若时间大于 1 天,则将以“1 天”为基准四舍五入到最接近的值

示例

// Sets eVar1 to "10.5 hours".
// 38242 seconds equals 10 hours, 37 minutes, and 22 seconds. Since the tf argument is not set, the value returned is the number of seconds converted to the nearest quarter-hour benchmark.
s.eVar1 = formatTime(38242);

// Sets eVar4 to "10.75 hours".
// 38250 seconds equals 10 hours, 37 minutes, and 30 seconds. This value rounds up to the nearest quarter hour.
s.eVar4 = formatTime(38250);

// Sets eVar9 to "637.5 minutes".
s.eVar9 = formatTime(38242, "m");

// Sets eVar14 to "640 minutes".
// The tf argument forces the returned value to minutes, while the bml argument forces the value to the nearest 20-minute increment.
s.eVar14 = formatTime(38242, "m", 20);

// Sets eVar2 to "126 seconds", the closest 2-second benchmark to 125 seconds.
s.eVar2 = formatTime(125, "s", 2);

// Sets eVar7 to "3 minutes", the closest 3-minute benchmark to 125 seconds.
s.eVar7 = formatTime(125, "m", 3);

// Sets eVar55 to "2.4 minutes, the closest 2/5-minute benchmark to 145 seconds.
s.eVar55 = formatTime(145, "m", .4);

版本历史记录

2.0(2021 年 3 月 19 日)

  • 以上下文数据形式添加了版本号。

1.1(2018 年 5 月 21 日)

  • 添加了 bml 参数,以便在舍入方面更灵活

1.0(2018 年 4 月 15 日)

  • 第一版。
已自动翻译
使用语言选择器查看此页面的英文版本。
翻译有帮助吗?

Ask AI

Not sure where to start?
Ask me anything about Adobe products.

Type your question or pick a suggestion below.

Use of this AI chatbot is subject to Adobe's Privacy Policy. Don't share sensitive data. AI responses are not your Content, may be inaccurate, and any offers provided are non-binding. Generative AI Terms.