跳至主要内容

DateTime.ToText

傳回 datetime 值的文字表示。

Syntax

DateTime.ToText(
dateTime as datetime,
optional options as any,
optional culture as text
) as text

Remarks

傳回以文字表示的 dateTime。可能會提供選用的 record 參數 (options) 來指定其他屬性。culture 僅用於舊版工作流程。record 可能包含下列欄位:

若要支援舊版工作流程,optionsculture 也可以是文字值。這與 options = [Format = options, Culture = culture] 具有相同的行爲。

Examples

Example #1

#datetime(2010, 12, 31, 01, 30, 25) 轉換爲 text 值。結果輸出可能因目前文化特性而有所不同。

DateTime.ToText(#datetime(2010, 12, 31, 01, 30, 25))

Result:

"12/31/2010 1:30:25 AM"

Example #2

使用自訂格式和德文文化特性進行轉換。

DateTime.ToText(#datetime(2010, 12, 30, 2, 4, 50.36973), [Format="dd MMM yyyy HH:mm:ss.ffffff", Culture="de-DE"])

Result:

"30 Dez 2010 02:04:50.369730"

Example #3

使用 ISO 8601 模式進行轉換。

DateTime.ToText(#datetime(2000, 2, 8, 3, 45, 12),[Format="yyyy-MM-dd'T'HH:mm:ss'Z'", Culture="en-US"])

Result:

"2000-02-08T03:45:12Z"

Category

DateTime