使用外掛程式

formatTime 函數會使用以下引數:

  • ns (必要,整數):要轉換或格式化的秒數

  • tf (可選,字串):傳回秒數的格式類型;預設為秒

    • 如果您想要以天為單位的時間,請設為 "d" (預設會捨入為最接近的 1/4 天基準)
    • 如果您想要以小時為單位的時間,請設為 "h" (預設會捨入為最接近的 1/4 小時基準)
    • 如果您想要以分鐘為單位的時間,請設為 "m" (預設會捨入為最接近的 1/2 分鐘基準)
    • 如果您想要以秒為單位的時間,請設為 "s" (預設會捨入為最接近的 5 秒基準)
  • bml (可選,數字):捨入基準的長度。 預設值為 tf 引數中所列的基準

此函數會使用您在 tf 引數中指定的單位來傳回格式化的秒數。 如果 tf 引數未設定:

  • 小於一分鐘的值會捨入為最接近的 5 秒基準
  • 介於一分鐘到一小時之間的值,會捨入為最接近的 1/2 分鐘基準
  • 介於一小時到一天之間的值,會捨入為最接近的四分之一小時基準
  • 大於一天的值會捨入為最接近的天基準

範例

// 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.