

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# util.time 中的時間協助程式
<a name="time-helpers-in-util-time-js"></a>

`util.time` 變數包含日期時間方法，可協助產生時間戳記、在日期時間格式之間轉換，以及剖析日期時間字串。日期時間格式的語法是根據 [DateTimeFormatter](https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html)，您可以參考以取得更詳細的文件。

## 時間使用率清單
<a name="utility-helpers-in-time-list-js"></a>

 **`util.time.nowISO8601()`**  
以 [ISO8601 格式](https://en.wikipedia.org/wiki/ISO_8601)傳回 UTC 的字串表示方式。

 **`util.time.nowEpochSeconds()`**  
傳回從 1970-01-01T00:00:00Z 的 epoch 到現在的秒數。

 **`util.time.nowEpochMilliSeconds()`**  
傳回從 1970-01-01T00:00:00Z 的 epoch 到現在的毫秒數。

 **`util.time.nowFormatted(String)`**  
使用字串輸入類型的指定格式，傳回 UTC 中目前時間戳記的字串。

 **`util.time.nowFormatted(String, String)`**  
使用字串輸入類型的指定格式和時區，傳回時區目前時間戳記的字串。

 **`util.time.parseFormattedToEpochMilliSeconds(String, String)`**  
剖析以字串形式傳遞的時間戳記，以及包含時區的格式，然後傳回自 epoch 以來以毫秒為單位的時間戳記。

 **`util.time.parseFormattedToEpochMilliSeconds(String, String, String)`**  
剖析以字串形式傳遞的時間戳記，以及格式和時區，然後以毫秒為單位傳回自 epoch 以來的時間戳記。

 **`util.time.parseISO8601ToEpochMilliSeconds(String)`**  
剖析以字串形式傳遞的 ISO8601 時間戳記，然後將時間戳記傳回為自 epoch 以來的毫秒。

 **`util.time.epochMilliSecondsToSeconds(long)`**  
將 epoch 毫秒時間戳記轉換為 epoch 秒時間戳記。

 **`util.time.epochMilliSecondsToISO8601(long)`**  
將 epoch 毫秒時間戳記轉換為 ISO8601 時間戳記。

 **`util.time.epochMilliSecondsToFormatted(long, String)`**  
將 epoch 毫秒時間戳記轉換為根據 UTC 格式提供的時間戳記。

 **`util.time.epochMilliSecondsToFormatted(long, String, String)`**  
將長傳遞的 epoch 毫秒時間戳記轉換為根據所提供時區中提供的格式格式化的時間戳記。