日期時間操作
138 個節點
本頁內容 138
加上時間間隔
函數過載 1/4
加上時間間隔(值: 時間日期, 增量: TimeSpan) -> 時間日期
DateTime Add(DateTime value, TimeSpan delta)
給時間日期加上一段時間間隔。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | 時間日期 | — | |
| 增量 | TimeSpan | — |
返回
| 結果 | 時間日期 |
過載 2/4
加上時間間隔(值: TimeOnly, 增量: TimeSpan) -> TimeOnly
TimeOnly Add(TimeOnly value, TimeSpan delta)
給時刻加上一段時間間隔。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | TimeOnly | — | |
| 增量 | TimeSpan | — |
返回
| 結果 | TimeOnly |
過載 3/4
加上時間間隔 -> (結果: TimeOnly, 跨越天數: 整數)
值: TimeOnly
增量: TimeSpanTimeOnly Add(
TimeOnly value,
TimeSpan delta,
out int wrappedDays)給時刻加上一段時間間隔,越過午夜時繞回,並報告鐘錶繞過了幾天。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | TimeOnly | — | The starting time of day. |
| 增量 | TimeSpan | — | The duration to add; negative moves back. |
返回
| 結果 | TimeOnly |
| 跨越天數 | 整數 |
過載 4/4
加上時間間隔(左側: TimeSpan, 右側: TimeSpan) -> TimeSpan
TimeSpan Add(TimeSpan left, TimeSpan right)
把兩個時間間隔相加。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 左側 | TimeSpan | — | |
| 右側 | TimeSpan | — |
返回
| 結果 | TimeSpan |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
加天數
函數過載 1/2
加天數(值: 時間日期, 天數: 數字) -> 時間日期
DateTime AddDays(DateTime value, double days)
把時間日期按天數前後移動,天數可以是小數(0.5 即十二小時)。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | 時間日期 | — | The starting date and time; its kind is kept. |
| 天數 | 數字 | — | The number of days to add; negative moves back. |
返回
| 結果 | 時間日期 |
過載 2/2
加天數(值: DateOnly, 天數: 整數) -> DateOnly
DateOnly AddDays(DateOnly value, int days)
給日期加上若干天。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | DateOnly | — | |
| 天數 | 整數 | — |
返回
| 結果 | DateOnly |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
加小時數
函數過載 1/3
加小時數(值: 時間日期, 小時數: 數字) -> 時間日期
DateTime AddHours(DateTime value, double hours)
把時間日期按小時數前後移動,可以是小數。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | 時間日期 | — | The starting date and time; its kind is kept. |
| 小時數 | 數字 | — | The number of hours to add; negative moves back. |
返回
| 結果 | 時間日期 |
過載 2/3
加小時數(值: TimeOnly, 小時數: 數字) -> TimeOnly
TimeOnly AddHours(TimeOnly value, double hours)
把時刻按小時數前後移動,越過午夜時繞回(22:00 加 3 小時為 01:00)。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | TimeOnly | — | The starting time of day. |
| 小時數 | 數字 | — | The number of hours to add, which may be fractional or negative. |
返回
| 結果 | TimeOnly |
過載 3/3
加小時數 -> (結果: TimeOnly, 跨越天數: 整數)
值: TimeOnly
小時數: 數字TimeOnly AddHours(
TimeOnly value,
double hours,
out int wrappedDays)把時刻按小時數前後移動,越過午夜時繞回,並報告鐘錶繞過了幾天。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | TimeOnly | — | The starting time of day. |
| 小時數 | 數字 | — | The number of hours to add, which may be fractional or negative. |
返回
| 結果 | TimeOnly |
| 跨越天數 | 整數 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
加微秒數
函數把時間日期按微秒數前後移動,可以是小數。
加微秒數(值: 時間日期, 微秒數: 數字) -> 時間日期
DateTime AddMicroseconds(DateTime value, double microseconds)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | 時間日期 | — | The starting date and time; its kind is kept. |
| 微秒數 | 數字 | — | The number of microseconds to add; negative moves back. |
返回
| 結果 | 時間日期 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
加毫秒數
函數把時間日期按毫秒數前後移動,可以是小數。
加毫秒數(值: 時間日期, 毫秒數: 數字) -> 時間日期
DateTime AddMilliseconds(DateTime value, double milliseconds)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | 時間日期 | — | The starting date and time; its kind is kept. |
| 毫秒數 | 數字 | — | The number of milliseconds to add; negative moves back. |
返回
| 結果 | 時間日期 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
加分鐘數
函數過載 1/3
加分鐘數(值: 時間日期, 分鐘數: 數字) -> 時間日期
DateTime AddMinutes(DateTime value, double minutes)
把時間日期按分鐘數前後移動,可以是小數。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | 時間日期 | — | The starting date and time; its kind is kept. |
| 分鐘數 | 數字 | — | The number of minutes to add; negative moves back. |
返回
| 結果 | 時間日期 |
過載 2/3
加分鐘數(值: TimeOnly, 分鐘數: 數字) -> TimeOnly
TimeOnly AddMinutes(TimeOnly value, double minutes)
把時刻按分鐘數前後移動,越過午夜時繞回。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | TimeOnly | — | The starting time of day. |
| 分鐘數 | 數字 | — | The number of minutes to add, which may be fractional or negative. |
返回
| 結果 | TimeOnly |
過載 3/3
加分鐘數 -> (結果: TimeOnly, 跨越天數: 整數)
值: TimeOnly
分鐘數: 數字TimeOnly AddMinutes(
TimeOnly value,
double minutes,
out int wrappedDays)把時刻按分鐘數前後移動,越過午夜時繞回,並報告鐘錶繞過了幾天。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | TimeOnly | — | The starting time of day. |
| 分鐘數 | 數字 | — | The number of minutes to add, which may be fractional or negative. |
返回
| 結果 | TimeOnly |
| 跨越天數 | 整數 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
加月數
函數過載 1/2
加月數(值: 時間日期, 月數: 整數) -> 時間日期
DateTime AddMonths(DateTime value, int months)
把時間日期按整月前後移動,時刻保持不變。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | 時間日期 | — | The starting date and time; its kind is kept. |
| 月數 | 整數 | — | The number of months to add, from -120000 to 120000; negative moves back. |
返回
| 結果 | 時間日期 |
備註
If the day does not exist in the target month it is clamped to that month's last day, so January 31 plus one month is February 28 (or 29 in a leap year).
過載 2/2
加月數(值: DateOnly, 月數: 整數) -> DateOnly
DateOnly AddMonths(DateOnly value, int months)
把日期按整月前後移動。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | DateOnly | — | The starting date. |
| 月數 | 整數 | — | The number of months to add; negative moves back. |
返回
| 結果 | DateOnly |
備註
If the day does not exist in the target month it is clamped to that month's last day, so January 31 plus one month is February 28 (or 29 in a leap year).
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
加秒數
函數把時間日期按秒數前後移動,可以是小數。
加秒數(值: 時間日期, 秒數: 數字) -> 時間日期
DateTime AddSeconds(DateTime value, double seconds)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | 時間日期 | — | The starting date and time; its kind is kept. |
| 秒數 | 數字 | — | The number of seconds to add; negative moves back. |
返回
| 結果 | 時間日期 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
加計時週期數
函數把時間日期按計時週期數前後移動,一個計時週期為 100 納秒。
加計時週期數(值: 時間日期, 計時週期數: 大整數) -> 時間日期
DateTime AddTicks(DateTime value, long ticks)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | 時間日期 | — | The starting date and time; its kind is kept. |
| 計時週期數 | 大整數 | — | The number of ticks to add; negative moves back. |
返回
| 結果 | 時間日期 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
加年數
函數過載 1/2
加年數(值: 時間日期, 年數: 整數) -> 時間日期
DateTime AddYears(DateTime value, int years)
把時間日期按整年前後移動,月、日和時刻保持不變。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | 時間日期 | — | The starting date and time; its kind is kept. |
| 年數 | 整數 | — | The number of years to add; negative moves back. |
返回
| 結果 | 時間日期 |
備註
February 29 moved to a year that is not a leap year becomes February 28.
過載 2/2
加年數(值: DateOnly, 年數: 整數) -> DateOnly
DateOnly AddYears(DateOnly value, int years)
把日期按整年前後移動,月和日保持不變。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | DateOnly | — | The starting date. |
| 年數 | 整數 | — | The number of years to add; negative moves back. |
返回
| 結果 | DateOnly |
備註
February 29 moved to a year that is not a leap year becomes February 28.
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
比較
函數過載 1/4
比較(左側: 時間日期, 右側: 時間日期) -> 整數
int Compare(DateTime left, DateTime right)
比較兩個時間日期。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 左側 | 時間日期 | — | |
| 右側 | 時間日期 | — |
返回
| 結果 | 整數 |
備註
The comparison uses the underlying tick values and does not convert values based on DateTime.Kind.
To compare actual points in time, convert both values to UTC first.
過載 2/4
比較(左側: DateOnly, 右側: DateOnly) -> 整數
int Compare(DateOnly left, DateOnly right)
比較兩個日期。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 左側 | DateOnly | — | |
| 右側 | DateOnly | — |
返回
| 結果 | 整數 |
過載 3/4
比較(左側: TimeOnly, 右側: TimeOnly) -> 整數
int Compare(TimeOnly left, TimeOnly right)
比較兩個時刻。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 左側 | TimeOnly | — | |
| 右側 | TimeOnly | — |
返回
| 結果 | 整數 |
過載 4/4
比較(左側: TimeSpan, 右側: TimeSpan) -> 整數
int Compare(TimeSpan left, TimeSpan right)
比較兩個時間間隔。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 左側 | TimeSpan | — | |
| 右側 | TimeSpan | — |
返回
| 結果 | 整數 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
建立時間日期
函數過載 1/8
建立時間日期(計時週期數: 大整數) -> 時間日期
DateTime Create(long ticks)
用計時週期數建立時間日期。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 計時週期數 | 大整數 | — |
返回
| 結果 | 時間日期 |
過載 2/8
建立時間日期(計時週期數: 大整數, 種類: DateTimeKind) -> 時間日期
DateTime Create(long ticks, DateTimeKind kind)
用計時週期數建立時間日期,並標為本地時間、UTC 或未指定。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 計時週期數 | 大整數 | — | The number of 100-nanosecond ticks since 0001-01-01 00:00:00; must be between 0 and the ticks of DateTime.MaxValue, otherwise an System.ArgumentOutOfRangeException is thrown. |
| 種類 | DateTimeKind | — | Whether the value is local time, UTC or unspecified. |
返回
| 結果 | 時間日期 |
過載 3/8
建立時間日期(年: 整數, 月: 整數, 日: 整數) -> 時間日期
DateTime Create(int year, int month, int day)
建立給定日曆日期午夜時分的時間日期。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 年 | 整數 | — | The year, from 1 to 9999. |
| 月 | 整數 | — | The month, from 1 to 12. |
| 日 | 整數 | — | The day of the month, from 1 to the number of days in that month. |
返回
| 結果 | 時間日期 |
過載 4/8
建立時間日期 -> 時間日期
年: 整數
月: 整數
日: 整數
時: 整數
分: 整數
第二個: 整數DateTime Create(
int year,
int month,
int day,
int hour,
int minute,
int second)用日曆日期和精確到秒的時刻建立時間日期。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 年 | 整數 | — | The year, from 1 to 9999. |
| 月 | 整數 | — | The month, from 1 to 12. |
| 日 | 整數 | — | The day of the month, from 1 to the number of days in that month. |
| 時 | 整數 | — | The hour, from 0 to 23. |
| 分 | 整數 | — | The minute, from 0 to 59. |
| 第二個 | 整數 | — | The second, from 0 to 59. |
返回
| 結果 | 時間日期 |
過載 5/8
建立時間日期 -> 時間日期
年: 整數
月: 整數
日: 整數
時: 整數
分: 整數
第二個: 整數
種類: DateTimeKindDateTime Create(
int year,
int month,
int day,
int hour,
int minute,
int second,
DateTimeKind kind)用日曆日期和精確到秒的時刻建立時間日期,並標為本地時間、UTC 或未指定。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 年 | 整數 | — | The year, from 1 to 9999. |
| 月 | 整數 | — | The month, from 1 to 12. |
| 日 | 整數 | — | The day of the month, from 1 to the number of days in that month. |
| 時 | 整數 | — | The hour, from 0 to 23. |
| 分 | 整數 | — | The minute, from 0 to 59. |
| 第二個 | 整數 | — | The second, from 0 to 59. |
| 種類 | DateTimeKind | — | Whether the value is local time, UTC or unspecified. |
返回
| 結果 | 時間日期 |
過載 6/8
建立時間日期 -> 時間日期
年: 整數
月: 整數
日: 整數
時: 整數
分: 整數
第二個: 整數
毫秒: 整數DateTime Create(
int year,
int month,
int day,
int hour,
int minute,
int second,
int millisecond)用日曆日期和精確到毫秒的時刻建立時間日期。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 年 | 整數 | — | The year, from 1 to 9999. |
| 月 | 整數 | — | The month, from 1 to 12. |
| 日 | 整數 | — | The day of the month, from 1 to the number of days in that month. |
| 時 | 整數 | — | The hour, from 0 to 23. |
| 分 | 整數 | — | The minute, from 0 to 59. |
| 第二個 | 整數 | — | The second, from 0 to 59. |
| 毫秒 | 整數 | — | The millisecond, from 0 to 999. |
返回
| 結果 | 時間日期 |
過載 7/8
建立時間日期 -> 時間日期
年: 整數
月: 整數
日: 整數
時: 整數
分: 整數
第二個: 整數
毫秒: 整數
種類: DateTimeKindDateTime Create(
int year,
int month,
int day,
int hour,
int minute,
int second,
int millisecond,
DateTimeKind kind)用日曆日期和精確到毫秒的時刻建立時間日期,並標為本地時間、UTC 或未指定。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 年 | 整數 | — | The year, from 1 to 9999. |
| 月 | 整數 | — | The month, from 1 to 12. |
| 日 | 整數 | — | The day of the month, from 1 to the number of days in that month. |
| 時 | 整數 | — | The hour, from 0 to 23. |
| 分 | 整數 | — | The minute, from 0 to 59. |
| 第二個 | 整數 | — | The second, from 0 to 59. |
| 毫秒 | 整數 | — | The millisecond, from 0 to 999. |
| 種類 | DateTimeKind | — | Whether the value is local time, UTC or unspecified. |
返回
| 結果 | 時間日期 |
過載 8/8
建立時間日期 -> 時間日期
年: 整數
月: 整數
日: 整數
時: 整數
分: 整數
第二個: 整數
毫秒: 整數
微秒: 整數
種類: DateTimeKindDateTime Create(
int year,
int month,
int day,
int hour,
int minute,
int second,
int millisecond,
int microsecond,
DateTimeKind kind = DateTimeKind.Unspecified)用日曆日期和精確到微秒的時刻建立時間日期,可標為本地時間或 UTC。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 年 | 整數 | — | The year, from 1 to 9999. |
| 月 | 整數 | — | The month, from 1 to 12. |
| 日 | 整數 | — | The day of the month, from 1 to the number of days in that month. |
| 時 | 整數 | — | The hour, from 0 to 23. |
| 分 | 整數 | — | The minute, from 0 to 59. |
| 第二個 | 整數 | — | The second, from 0 to 59. |
| 毫秒 | 整數 | — | The millisecond, from 0 to 999. |
| 微秒 | 整數 | — | The microsecond, from 0 to 999. |
| 種類 | DateTimeKind | Unspecified | Whether the value is local time, UTC or unspecified; unspecified when left out. |
返回
| 結果 | 時間日期 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
建立日期
函數過載 1/2
建立日期(年: 整數, 月: 整數, 日: 整數) -> DateOnly
DateOnly CreateDateOnly(int year, int month, int day)
用年、月、日建立日期。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 年 | 整數 | — | |
| 月 | 整數 | — | |
| 日 | 整數 | — |
返回
| 結果 | DateOnly |
過載 2/2
建立日期 -> DateOnly
年: 整數
月: 整數
日: 整數
日曆: CalendarDateOnly CreateDateOnly(
int year,
int month,
int day,
Calendar calendar)用另一種曆法(如希伯來曆或日本歷)中的年、月、日建立日期。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 年 | 整數 | — | The year in Calendar. |
| 月 | 整數 | — | The month in Calendar. |
| 日 | 整數 | — | The day of the month in Calendar. |
| 日曆 | Calendar | — | The calendar the year, month and day are expressed in; must not be null. |
返回
| 結果 | DateOnly |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
建立時刻
函數過載 1/4
建立時刻(時: 整數, 分: 整數) -> TimeOnly
TimeOnly CreateTimeOnly(int hour, int minute)
用時和分建立時刻。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 時 | 整數 | — | |
| 分 | 整數 | — |
返回
| 結果 | TimeOnly |
過載 2/4
建立時刻(時: 整數, 分: 整數, 第二個: 整數) -> TimeOnly
TimeOnly CreateTimeOnly(int hour, int minute, int second)
用時、分、秒建立時刻。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 時 | 整數 | — | The hour, from 0 to 23. |
| 分 | 整數 | — | The minute, from 0 to 59. |
| 第二個 | 整數 | — | The second, from 0 to 59. |
返回
| 結果 | TimeOnly |
過載 3/4
建立時刻 -> TimeOnly
時: 整數
分: 整數
第二個: 整數
毫秒: 整數TimeOnly CreateTimeOnly(
int hour,
int minute,
int second,
int millisecond)用時、分、秒、毫秒建立時刻。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 時 | 整數 | — | The hour, from 0 to 23. |
| 分 | 整數 | — | The minute, from 0 to 59. |
| 第二個 | 整數 | — | The second, from 0 to 59. |
| 毫秒 | 整數 | — | The millisecond, from 0 to 999. |
返回
| 結果 | TimeOnly |
過載 4/4
建立時刻 -> TimeOnly
時: 整數
分: 整數
第二個: 整數
毫秒: 整數
微秒: 整數TimeOnly CreateTimeOnly(
int hour,
int minute,
int second,
int millisecond,
int microsecond)用時、分、秒、毫秒、微秒建立時刻。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 時 | 整數 | — | The hour, from 0 to 23. |
| 分 | 整數 | — | The minute, from 0 to 59. |
| 第二個 | 整數 | — | The second, from 0 to 59. |
| 毫秒 | 整數 | — | The millisecond, from 0 to 999. |
| 微秒 | 整數 | — | The microsecond, from 0 to 999. |
返回
| 結果 | TimeOnly |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
建立時間間隔
函數過載 1/5
建立時間間隔(計時週期數: 大整數) -> TimeSpan
TimeSpan CreateTimeSpan(long ticks)
用計時週期數建立時間間隔。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 計時週期數 | 大整數 | — |
返回
| 結果 | TimeSpan |
過載 2/5
建立時間間隔(小時數: 整數, 分鐘數: 整數, 秒數: 整數) -> TimeSpan
TimeSpan CreateTimeSpan(int hours, int minutes, int seconds)
用時、分、秒建立時間間隔。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 小時數 | 整數 | — | The number of hours. |
| 分鐘數 | 整數 | — | The number of minutes. |
| 秒數 | 整數 | — | The number of seconds. |
返回
| 結果 | TimeSpan |
備註
The parts are added together, so they may exceed their usual ranges or be negative: 0 hours, 90 minutes and 0 seconds is one and a half hours. An System.ArgumentOutOfRangeException is thrown if the total is beyond TimeSpan.MaxValue or TimeSpan.MinValue.
過載 3/5
建立時間間隔 -> TimeSpan
天數: 整數
小時數: 整數
分鐘數: 整數
秒數: 整數TimeSpan CreateTimeSpan(
int days,
int hours,
int minutes,
int seconds)用天、時、分、秒建立時間間隔。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 天數 | 整數 | — | The number of days. |
| 小時數 | 整數 | — | The number of hours. |
| 分鐘數 | 整數 | — | The number of minutes. |
| 秒數 | 整數 | — | The number of seconds. |
返回
| 結果 | TimeSpan |
備註
The parts are added together, so they may exceed their usual ranges or be negative. An System.ArgumentOutOfRangeException is thrown if the total is beyond TimeSpan.MaxValue or TimeSpan.MinValue.
過載 4/5
建立時間間隔 -> TimeSpan
天數: 整數
小時數: 整數
分鐘數: 整數
秒數: 整數
毫秒數: 整數TimeSpan CreateTimeSpan(
int days,
int hours,
int minutes,
int seconds,
int milliseconds)用天、時、分、秒、毫秒建立時間間隔。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 天數 | 整數 | — | The number of days. |
| 小時數 | 整數 | — | The number of hours. |
| 分鐘數 | 整數 | — | The number of minutes. |
| 秒數 | 整數 | — | The number of seconds. |
| 毫秒數 | 整數 | — | The number of milliseconds. |
返回
| 結果 | TimeSpan |
備註
The parts are added together, so they may exceed their usual ranges or be negative. An System.ArgumentOutOfRangeException is thrown if the total is beyond TimeSpan.MaxValue or TimeSpan.MinValue.
過載 5/5
建立時間間隔 -> TimeSpan
天數: 整數
小時數: 整數
分鐘數: 整數
秒數: 整數
毫秒數: 整數
微秒數: 整數TimeSpan CreateTimeSpan(
int days,
int hours,
int minutes,
int seconds,
int milliseconds,
int microseconds)用天、時、分、秒、毫秒、微秒建立時間間隔。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 天數 | 整數 | — | The number of days. |
| 小時數 | 整數 | — | The number of hours. |
| 分鐘數 | 整數 | — | The number of minutes. |
| 秒數 | 整數 | — | The number of seconds. |
| 毫秒數 | 整數 | — | The number of milliseconds. |
| 微秒數 | 整數 | — | The number of microseconds. |
返回
| 結果 | TimeSpan |
備註
The parts are added together, so they may exceed their usual ranges or be negative. An System.ArgumentOutOfRangeException is thrown if the total is beyond TimeSpan.MaxValue or TimeSpan.MinValue.
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
日期部分
函數取得時間日期的日期部分。
日期部分(值: 時間日期) -> 時間日期
DateTime Date(DateTime value)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | 時間日期 | — |
返回
| 結果 | 時間日期 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
從時間日期取日期
函數取時間日期的日曆日期,去掉其時刻。
從時間日期取日期(值: 時間日期) -> DateOnly
DateOnly DateOnlyFromDateTime(DateTime value)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | 時間日期 | — | The date and time to take the date from; its kind is ignored and no time-zone conversion is made. |
返回
| 結果 | DateOnly |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
從日序號取日期
函數用天數編號建立日期,即公曆中自 0001-01-01 起的天數。
從日序號取日期(日序號: 整數) -> DateOnly
DateOnly DateOnlyFromDayNumber(int dayNumber)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 日序號 | 整數 | — | The number of days since 0001-01-01, from 0 (0001-01-01) to 3652058 (9999-12-31); any other value throws an System.ArgumentOutOfRangeException. |
返回
| 結果 | DateOnly |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
日
函數過載 1/2
日(值: 時間日期) -> 整數
int Day(DateTime value)
取得時間日期是當月的第幾天。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | 時間日期 | — | The date and time. |
返回
| 結果 | 整數 |
過載 2/2
日(值: DateOnly) -> 整數
int Day(DateOnly value)
取得日期是當月的第幾天。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | DateOnly | — | The date. |
返回
| 結果 | 整數 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
日序號
函數把日期表示為一個天數編號,即自 0001-01-01 起的天數;兩個天數編號相減即為兩者相隔的天數。
日序號(值: DateOnly) -> 整數
int DayNumber(DateOnly value)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | DateOnly | — | The date. |
返回
| 結果 | 整數 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
星期幾
函數過載 1/2
星期幾(值: 時間日期) -> DayOfWeek
DayOfWeek DayOfWeek(DateTime value)
取得時間日期是星期幾。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | 時間日期 | — | The date and time. |
返回
| 結果 | DayOfWeek |
過載 2/2
星期幾(值: DateOnly) -> DayOfWeek
DayOfWeek DayOfWeek(DateOnly value)
取得日期是星期幾。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | DateOnly | — | The date. |
返回
| 結果 | DayOfWeek |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
一年中的第幾天
函數過載 1/2
一年中的第幾天(值: 時間日期) -> 整數
int DayOfYear(DateTime value)
取得時間日期是當年的第幾天。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | 時間日期 | — | The date and time. |
返回
| 結果 | 整數 |
過載 2/2
一年中的第幾天(值: DateOnly) -> 整數
int DayOfYear(DateOnly value)
取得日期是當年的第幾天。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | DateOnly | — | The date. |
返回
| 結果 | 整數 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
天數
函數取得時間間隔的天數部分。
天數(值: TimeSpan) -> 整數
int Days(TimeSpan value)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | TimeSpan | — |
返回
| 結果 | 整數 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
相隔天數
函數計算從一個日期到另一個日期相隔的日曆天數。
相隔天數(左側: DateOnly, 右側: DateOnly) -> 整數
int DaysBetween(DateOnly left, DateOnly right)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 左側 | DateOnly | — | The later date. |
| 右側 | DateOnly | — | The earlier date. |
返回
| 結果 | 整數 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
月份天數
函數給出公曆中某年某月的天數,已考慮閏年。
月份天數(年: 整數, 月: 整數) -> 整數
int DaysInMonth(int year, int month)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 年 | 整數 | — | The year, from 1 to 9999. |
| 月 | 整數 | — | The month, from 1 to 12; any other value throws an System.ArgumentOutOfRangeException. |
返回
| 結果 | 整數 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
分解
函數過載 1/5
分解(值: 時間日期) -> (年: 整數, 月: 整數, 日: 整數)
void Deconstruct(
DateTime value,
out int year,
out int month,
out int day)把時間日期拆分為年、月、日。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | 時間日期 | — |
返回
| 年 | 整數 |
| 月 | 整數 |
| 日 | 整數 |
過載 2/5
分解(值: 時間日期) -> (日期: DateOnly, 時間: TimeOnly)
void Deconstruct(
DateTime value,
out DateOnly date,
out TimeOnly time)把時間日期拆分為日曆日期和時刻。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | 時間日期 | — | The date and time to split; its kind is dropped and no time-zone conversion is made. |
返回
| 日期 | DateOnly |
| 時間 | TimeOnly |
過載 3/5
分解(值: DateOnly) -> (年: 整數, 月: 整數, 日: 整數)
void Deconstruct(
DateOnly value,
out int year,
out int month,
out int day)把日期拆分為年、月、日三個數。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | DateOnly | — | The date to split. |
返回
| 年 | 整數 |
| 月 | 整數 |
| 日 | 整數 |
過載 4/5
分解(值: TimeOnly) -> (時: 整數, 分: 整數, 第二個: 整數)
void Deconstruct(
TimeOnly value,
out int hour,
out int minute,
out int second)把時刻拆分為時、分、秒;不足一秒的部分捨去。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | TimeOnly | — | The time of day to split. |
返回
| 時 | 整數 |
| 分 | 整數 |
| 第二個 | 整數 |
過載 5/5
分解(值: TimeSpan) -> (天數: 整數, 小時數: 整數, 分鐘數: 整數, 秒數: 整數)
void Deconstruct(
TimeSpan value,
out int days,
out int hours,
out int minutes,
out int seconds)把時間間隔拆分為整天、時、分、秒;不足一秒的部分捨去,負的時間間隔各部分均為負。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | TimeSpan | — | The duration to split. |
返回
| 天數 | 整數 |
| 小時數 | 整數 |
| 分鐘數 | 整數 |
| 秒數 | 整數 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
除以
函數過載 1/2
除以(值: TimeSpan, 除數: 數字) -> TimeSpan
TimeSpan Divide(TimeSpan value, double divisor)
用一個數去除時間間隔,例如把它等分。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | TimeSpan | — | The duration to divide. |
| 除數 | 數字 | — | The number to divide by; NaN throws an System.ArgumentException, and zero throws an System.OverflowException. |
返回
| 結果 | TimeSpan |
過載 2/2
除以(左側: TimeSpan, 右側: TimeSpan) -> 數字
double Divide(TimeSpan left, TimeSpan right)
給出兩個時間間隔之比,例如一個能容納幾個另一個。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 左側 | TimeSpan | — | The duration to divide. |
| 右側 | TimeSpan | — | The duration to divide by; zero gives infinity, or NaN when Left is also zero, instead of an error. |
返回
| 結果 | 數字 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
絕對時長
函數取時間間隔的絕對長度,去掉其正負號。
絕對時長(值: TimeSpan) -> TimeSpan
TimeSpan Duration(TimeSpan value)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | TimeSpan | — | The duration; TimeSpan.MinValue throws an System.OverflowException because its absolute value does not fit. |
返回
| 結果 | TimeSpan |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
相等
函數過載 1/4
相等(左側: 時間日期, 右側: 時間日期) -> 真否
bool Equals(DateTime left, DateTime right)
檢查兩個時間日期是否相同。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 左側 | 時間日期 | — | The first date and time. |
| 右側 | 時間日期 | — | The second date and time. |
返回
| 結果 | 真否 |
備註
Only the tick values are compared and DateTime.Kind is ignored, so a local and a UTC value with the same clock reading are equal. Convert both to UTC first to compare actual points in time.
過載 2/4
相等(左側: DateOnly, 右側: DateOnly) -> 真否
bool Equals(DateOnly left, DateOnly right)
檢查兩個日期是否是同一天。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 左側 | DateOnly | — | The first date. |
| 右側 | DateOnly | — | The second date. |
返回
| 結果 | 真否 |
過載 3/4
相等(左側: TimeOnly, 右側: TimeOnly) -> 真否
bool Equals(TimeOnly left, TimeOnly right)
檢查兩個時刻是否相同,精確到計時週期。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 左側 | TimeOnly | — | The first time of day. |
| 右側 | TimeOnly | — | The second time of day. |
返回
| 結果 | 真否 |
過載 4/4
相等(左側: TimeSpan, 右側: TimeSpan) -> 真否
bool Equals(TimeSpan left, TimeSpan right)
檢查兩個時間間隔是否一樣長,精確到計時週期。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 左側 | TimeSpan | — | The first duration. |
| 右側 | TimeSpan | — | The second duration. |
返回
| 結果 | 真否 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
從二進位制值還原
函數從“轉為二進位制值”生成的數字還原時間日期,連同其時間型別。
從二進位制值還原(值: 大整數) -> 時間日期
DateTime FromBinary(long value)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | 大整數 | — | The packed number; one that does not encode a valid date throws an System.ArgumentException. |
返回
| 結果 | 時間日期 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
由日期和時刻組合
函數過載 1/2
由日期和時刻組合(日期: DateOnly, 時間: TimeOnly) -> 時間日期
DateTime FromDateOnlyTimeOnly(DateOnly date, TimeOnly time)
把日期和時刻合成一個時間日期。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 日期 | DateOnly | — | |
| 時間 | TimeOnly | — |
返回
| 結果 | 時間日期 |
過載 2/2
由日期和時刻組合 -> 時間日期
日期: DateOnly
時間: TimeOnly
種類: DateTimeKindDateTime FromDateOnlyTimeOnly(
DateOnly date,
TimeOnly time,
DateTimeKind kind)把一個日期和一個時刻合成一個時間日期,並標為本地時間、UTC 或未指定。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 日期 | DateOnly | — | The calendar date. |
| 時間 | TimeOnly | — | The time of day on that date. |
| 種類 | DateTimeKind | — | Whether the result is local time, UTC or unspecified. |
返回
| 結果 | 時間日期 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
從檔案時間轉換
函數把 Windows 檔案時間轉換為本機所在時區的時間日期。
從檔案時間轉換(值: 大整數) -> 時間日期
DateTime FromFileTime(long value)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | 大整數 | — | The number of 100-nanosecond intervals since 1601-01-01 00:00:00 UTC; a negative or too-large value throws an System.ArgumentOutOfRangeException. |
返回
| 結果 | 時間日期 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
從 UTC 檔案時間轉換
函數把 Windows 檔案時間轉換為 UTC 時間日期。
從 UTC 檔案時間轉換(值: 大整數) -> 時間日期
DateTime FromFileTimeUtc(long value)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | 大整數 | — | The number of 100-nanosecond intervals since 1601-01-01 00:00:00 UTC; a negative or too-large value throws an System.ArgumentOutOfRangeException. |
返回
| 結果 | 時間日期 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
從 OLE 自動化日期轉換
函數把 OLE 自動化日期(Excel 等 Office 應用表示日期所用的數字格式)轉換為時間日期。
從 OLE 自動化日期轉換(值: 數字) -> 時間日期
DateTime FromOADate(double value)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | 數字 | — | The number of days since 1899-12-30, with the time of day as the fraction; values outside -657435 to 2958466 (exclusive) throw an System.ArgumentException. |
返回
| 結果 | 時間日期 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
從 Unix 毫秒時間戳轉換
函數把 JavaScript 和許多 Web API 使用的毫秒級 Unix 時間戳轉換回 UTC 時間日期。
從 Unix 毫秒時間戳轉換(毫秒數: 大整數) -> 時間日期
DateTime FromUnixTimeMilliseconds(long milliseconds)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 毫秒數 | 大整數 | — | The number of milliseconds since 1970-01-01 00:00:00 UTC, from -62135596800000 to 253402300799999; any other value throws an System.ArgumentOutOfRangeException. |
返回
| 結果 | 時間日期 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
從 Unix 秒時間戳轉換
函數把秒級 Unix 時間戳轉換回 UTC 時間日期。
從 Unix 秒時間戳轉換(秒數: 大整數) -> 時間日期
DateTime FromUnixTimeSeconds(long seconds)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 秒數 | 大整數 | — | The number of seconds since 1970-01-01 00:00:00 UTC, from -62135596800 to 253402300799; any other value throws an System.ArgumentOutOfRangeException. |
返回
| 結果 | 時間日期 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
日期最大值
函數Gets the largest possible value of System.DateOnly.
日期最大值() -> DateOnly
DateOnly DateOnlyMaxValue()
返回
| 結果 | DateOnly |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
日期最小值
函數Gets the smallest possible value of System.DateOnly.
日期最小值() -> DateOnly
DateOnly DateOnlyMinValue()
返回
| 結果 | DateOnly |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
最大值
函數Gets the largest possible value of System.DateTime.
最大值() -> 時間日期
DateTime MaxValue()
返回
| 結果 | 時間日期 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
最小值
函數Gets the smallest possible value of System.DateTime.
最小值() -> 時間日期
DateTime MinValue()
返回
| 結果 | 時間日期 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
每計時週期納秒數
函數Gets the number of nanoseconds in one tick.
每計時週期納秒數() -> 大整數
long NanosecondsPerTick()
返回
| 結果 | 大整數 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
現在
函數Gets the current local date and time.
現在() -> 時間日期
DateTime Now()
返回
| 結果 | 時間日期 |
備註
The returned System.DateTime has DateTime.Kind set to DateTimeKind.Local.
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
每天計時週期數
函數Gets the number of ticks in one day.
每天計時週期數() -> 大整數
long TicksPerDay()
返回
| 結果 | 大整數 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
每小時計時週期數
函數Gets the number of ticks in one hour.
每小時計時週期數() -> 大整數
long TicksPerHour()
返回
| 結果 | 大整數 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
每微秒計時週期數
函數Gets the number of ticks in one microsecond.
每微秒計時週期數() -> 大整數
long TicksPerMicrosecond()
返回
| 結果 | 大整數 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
每毫秒計時週期數
函數Gets the number of ticks in one millisecond.
每毫秒計時週期數() -> 大整數
long TicksPerMillisecond()
返回
| 結果 | 大整數 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
每分鐘計時週期數
函數Gets the number of ticks in one minute.
每分鐘計時週期數() -> 大整數
long TicksPerMinute()
返回
| 結果 | 大整數 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
每秒計時週期數
函數Gets the number of ticks in one second.
每秒計時週期數() -> 大整數
long TicksPerSecond()
返回
| 結果 | 大整數 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
時刻最大值
函數Gets the largest possible value of System.TimeOnly.
時刻最大值() -> TimeOnly
TimeOnly TimeOnlyMaxValue()
返回
| 結果 | TimeOnly |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
時刻最小值
函數Gets the smallest possible value of System.TimeOnly.
時刻最小值() -> TimeOnly
TimeOnly TimeOnlyMinValue()
返回
| 結果 | TimeOnly |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
時間間隔最大值
函數Gets the largest possible value of System.TimeSpan.
時間間隔最大值() -> TimeSpan
TimeSpan TimeSpanMaxValue()
返回
| 結果 | TimeSpan |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
時間間隔最小值
函數Gets the smallest possible value of System.TimeSpan.
時間間隔最小值() -> TimeSpan
TimeSpan TimeSpanMinValue()
返回
| 結果 | TimeSpan |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
零時間間隔
函數Gets a zero-length System.TimeSpan.
零時間間隔() -> TimeSpan
TimeSpan TimeSpanZero()
返回
| 結果 | TimeSpan |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
今天
函數Gets the current local date with the time set to midnight.
今天() -> 時間日期
DateTime Today()
返回
| 結果 | 時間日期 |
備註
The returned System.DateTime has DateTime.Kind set to DateTimeKind.Local.
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
Unix 紀元
函數Gets the Unix epoch date and time: 1970-01-01 00:00:00 UTC.
Unix 紀元() -> 時間日期
DateTime UnixEpoch()
返回
| 結果 | 時間日期 |
備註
The returned System.DateTime has DateTime.Kind set to DateTimeKind.Utc.
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
目前 UTC 時間
函數Gets the current UTC date and time.
目前 UTC 時間() -> 時間日期
DateTime UtcNow()
返回
| 結果 | 時間日期 |
備註
The returned System.DateTime has DateTime.Kind set to DateTimeKind.Utc.
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
取得時間日期格式
函數過載 1/4
取得時間日期格式(值: 時間日期) -> 文字陣列
string[] GetDateTimeFormats(DateTime value)
用目前區域的每種標準格式寫出時間日期,便於看出該選哪種格式。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | 時間日期 | — | The date and time to format. |
返回
| 結果 | 文字陣列 |
過載 2/4
取得時間日期格式 -> 文字陣列
值: 時間日期
提供者: IFormatProviderstring[] GetDateTimeFormats(
DateTime value,
IFormatProvider provider)用給定區域的每種標準格式寫出時間日期。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | 時間日期 | — | The date and time to format. |
| 提供者 | IFormatProvider | — | The culture whose conventions to use, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
返回
| 結果 | 文字陣列 |
過載 3/4
取得時間日期格式(值: 時間日期, 格式: Char) -> 文字陣列
string[] GetDateTimeFormats(DateTime value, char format)
按目前區域中某一標準格式說明符的所有模式寫出時間日期。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | 時間日期 | — | The date and time to format. |
| 格式 | Char | — | A standard format specifier such as 'd', 'D', 't' or 'G'; one that is not a standard specifier throws a System.FormatException. |
返回
| 結果 | 文字陣列 |
過載 4/4
取得時間日期格式 -> 文字陣列
值: 時間日期
格式: Char
提供者: IFormatProviderstring[] GetDateTimeFormats(
DateTime value,
char format,
IFormatProvider provider)按給定區域中某一標準格式說明符的所有模式寫出時間日期。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | 時間日期 | — | The date and time to format. |
| 格式 | Char | — | A standard format specifier such as 'd', 'D', 't' or 'G'; one that is not a standard specifier throws a System.FormatException. |
| 提供者 | IFormatProvider | — | The culture whose conventions to use, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
返回
| 結果 | 文字陣列 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
大於
函數過載 1/4
大於(左側: 時間日期, 右側: 時間日期) -> 真否
bool GreaterThan(DateTime left, DateTime right)
檢查一個時間日期是否晚於另一個。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 左側 | 時間日期 | — | The date and time to test. |
| 右側 | 時間日期 | — | The date and time to compare against. |
返回
| 結果 | 真否 |
備註
Only the tick values are compared and DateTime.Kind is ignored.
過載 2/4
大於(左側: DateOnly, 右側: DateOnly) -> 真否
bool GreaterThan(DateOnly left, DateOnly right)
檢查一個日期是否在另一個之後。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 左側 | DateOnly | — | The date to test. |
| 右側 | DateOnly | — | The date to compare against. |
返回
| 結果 | 真否 |
過載 3/4
大於(左側: TimeOnly, 右側: TimeOnly) -> 真否
bool GreaterThan(TimeOnly left, TimeOnly right)
檢查一個時刻是否晚於另一個,從午夜算起,不繞回。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 左側 | TimeOnly | — | The time of day to test. |
| 右側 | TimeOnly | — | The time of day to compare against. |
返回
| 結果 | 真否 |
過載 4/4
大於(左側: TimeSpan, 右側: TimeSpan) -> 真否
bool GreaterThan(TimeSpan left, TimeSpan right)
檢查一個時間間隔是否比另一個長;負的時間間隔視為比零還短。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 左側 | TimeSpan | — | The duration to test. |
| 右側 | TimeSpan | — | The duration to compare against. |
返回
| 結果 | 真否 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
大於或等於
函數過載 1/4
大於或等於(左側: 時間日期, 右側: 時間日期) -> 真否
bool GreaterThanOrEqual(DateTime left, DateTime right)
檢查一個時間日期是否晚於或等於另一個。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 左側 | 時間日期 | — | The date and time to test. |
| 右側 | 時間日期 | — | The date and time to compare against. |
返回
| 結果 | 真否 |
備註
Only the tick values are compared and DateTime.Kind is ignored.
過載 2/4
大於或等於(左側: DateOnly, 右側: DateOnly) -> 真否
bool GreaterThanOrEqual(DateOnly left, DateOnly right)
檢查一個日期是否在另一個之後或與其是同一天。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 左側 | DateOnly | — | The date to test. |
| 右側 | DateOnly | — | The date to compare against. |
返回
| 結果 | 真否 |
過載 3/4
大於或等於(左側: TimeOnly, 右側: TimeOnly) -> 真否
bool GreaterThanOrEqual(TimeOnly left, TimeOnly right)
檢查一個時刻是否晚於或等於另一個,從午夜算起,不繞回。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 左側 | TimeOnly | — | The time of day to test. |
| 右側 | TimeOnly | — | The time of day to compare against. |
返回
| 結果 | 真否 |
過載 4/4
大於或等於(左側: TimeSpan, 右側: TimeSpan) -> 真否
bool GreaterThanOrEqual(TimeSpan left, TimeSpan right)
檢查一個時間間隔是否長於或等於另一個;負的時間間隔視為比零還短。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 左側 | TimeSpan | — | The duration to test. |
| 右側 | TimeSpan | — | The duration to compare against. |
返回
| 結果 | 真否 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
小時
函數過載 1/2
小時(值: 時間日期) -> 整數
int Hour(DateTime value)
取得時間日期的小時(24 小時制)。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | 時間日期 | — | The date and time. |
返回
| 結果 | 整數 |
過載 2/2
小時(值: TimeOnly) -> 整數
int Hour(TimeOnly value)
取得時刻的小時部分。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | TimeOnly | — |
返回
| 結果 | 整數 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
小時數
函數取得時間間隔的小時部分,即去掉整天后剩下的部分;要得到整個時間間隔摺合的小時數,請用“總小時數”。
小時數(值: TimeSpan) -> 整數
int Hours(TimeSpan value)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | TimeSpan | — | The duration. |
返回
| 結果 | 整數 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
是否介於兩者之間
函數檢查時刻是否落在某個範圍內,包括 22:00 到 06:00 這樣跨過午夜的範圍。
是否介於兩者之間 -> 真否
值: TimeOnly
起點: TimeOnly
終點: TimeOnlybool IsBetween(TimeOnly value, TimeOnly start, TimeOnly end)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | TimeOnly | — | The time of day to test. |
| 起點 | TimeOnly | — | The start of the range, included. |
| 終點 | TimeOnly | — | The end of the range, excluded; when earlier than Start the range runs through midnight. |
返回
| 結果 | 真否 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
是否為夏令時
函數檢查時間日期是否處於本機所在時區的夏令時內。
是否為夏令時(值: 時間日期) -> 真否
bool IsDaylightSavingTime(DateTime value)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | 時間日期 | — | The date and time; a UTC value always gives false, and a local or unspecified value is read as local time. |
返回
| 結果 | 真否 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
是否為閏年
函數判斷給定年份是否為閏年。
是否為閏年(年: 整數) -> 真否
bool IsLeapYear(int year)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 年 | 整數 | — |
返回
| 結果 | 真否 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
時間種類
函數說明時間日期被標為本地時間、UTC 還是未指定。
時間種類(值: 時間日期) -> DateTimeKind
DateTimeKind Kind(DateTime value)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | 時間日期 | — | The date and time to inspect. |
返回
| 結果 | DateTimeKind |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
小於
函數過載 1/4
小於(左側: 時間日期, 右側: 時間日期) -> 真否
bool LessThan(DateTime left, DateTime right)
檢查一個時間日期是否早於另一個。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 左側 | 時間日期 | — | The date and time to test. |
| 右側 | 時間日期 | — | The date and time to compare against. |
返回
| 結果 | 真否 |
備註
Only the tick values are compared and DateTime.Kind is ignored.
過載 2/4
小於(左側: DateOnly, 右側: DateOnly) -> 真否
bool LessThan(DateOnly left, DateOnly right)
檢查一個日期是否在另一個之前。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 左側 | DateOnly | — | The date to test. |
| 右側 | DateOnly | — | The date to compare against. |
返回
| 結果 | 真否 |
過載 3/4
小於(左側: TimeOnly, 右側: TimeOnly) -> 真否
bool LessThan(TimeOnly left, TimeOnly right)
檢查一個時刻是否早於另一個,從午夜算起,不繞回。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 左側 | TimeOnly | — | The time of day to test. |
| 右側 | TimeOnly | — | The time of day to compare against. |
返回
| 結果 | 真否 |
過載 4/4
小於(左側: TimeSpan, 右側: TimeSpan) -> 真否
bool LessThan(TimeSpan left, TimeSpan right)
檢查一個時間間隔是否比另一個短;負的時間間隔視為比零還短。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 左側 | TimeSpan | — | The duration to test. |
| 右側 | TimeSpan | — | The duration to compare against. |
返回
| 結果 | 真否 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
小於或等於
函數過載 1/4
小於或等於(左側: 時間日期, 右側: 時間日期) -> 真否
bool LessThanOrEqual(DateTime left, DateTime right)
檢查一個時間日期是否早於或等於另一個。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 左側 | 時間日期 | — | The date and time to test. |
| 右側 | 時間日期 | — | The date and time to compare against. |
返回
| 結果 | 真否 |
備註
Only the tick values are compared and DateTime.Kind is ignored.
過載 2/4
小於或等於(左側: DateOnly, 右側: DateOnly) -> 真否
bool LessThanOrEqual(DateOnly left, DateOnly right)
檢查一個日期是否在另一個之前或與其是同一天。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 左側 | DateOnly | — | The date to test. |
| 右側 | DateOnly | — | The date to compare against. |
返回
| 結果 | 真否 |
過載 3/4
小於或等於(左側: TimeOnly, 右側: TimeOnly) -> 真否
bool LessThanOrEqual(TimeOnly left, TimeOnly right)
檢查一個時刻是否早於或等於另一個,從午夜算起,不繞回。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 左側 | TimeOnly | — | The time of day to test. |
| 右側 | TimeOnly | — | The time of day to compare against. |
返回
| 結果 | 真否 |
過載 4/4
小於或等於(左側: TimeSpan, 右側: TimeSpan) -> 真否
bool LessThanOrEqual(TimeSpan left, TimeSpan right)
檢查一個時間間隔是否短於或等於另一個;負的時間間隔視為比零還短。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 左側 | TimeSpan | — | The duration to test. |
| 右側 | TimeSpan | — | The duration to compare against. |
返回
| 結果 | 真否 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
微秒
函數過載 1/2
微秒(值: 時間日期) -> 整數
int Microsecond(DateTime value)
取得時間日期的微秒部分。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | 時間日期 | — | The date and time. |
返回
| 結果 | 整數 |
過載 2/2
微秒(值: TimeOnly) -> 整數
int Microsecond(TimeOnly value)
取得時刻的微秒部分。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | TimeOnly | — | The time of day. |
返回
| 結果 | 整數 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
微秒數
函數取得時間間隔的微秒部分,即去掉整毫秒後剩下的部分;要得到整個時間間隔摺合的微秒數,請用“總微秒數”。
微秒數(值: TimeSpan) -> 整數
int Microseconds(TimeSpan value)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | TimeSpan | — | The duration. |
返回
| 結果 | 整數 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
毫秒
函數過載 1/2
毫秒(值: 時間日期) -> 整數
int Millisecond(DateTime value)
取得時間日期的毫秒部分。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | 時間日期 | — | The date and time. |
返回
| 結果 | 整數 |
過載 2/2
毫秒(值: TimeOnly) -> 整數
int Millisecond(TimeOnly value)
取得時刻的毫秒部分。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | TimeOnly | — | The time of day. |
返回
| 結果 | 整數 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
毫秒數
函數取得時間間隔的毫秒部分,即去掉整秒後剩下的部分;要得到整個時間間隔摺合的毫秒數,請用“總毫秒數”。
毫秒數(值: TimeSpan) -> 整數
int Milliseconds(TimeSpan value)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | TimeSpan | — | The duration. |
返回
| 結果 | 整數 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
分
函數過載 1/2
分(值: 時間日期) -> 整數
int Minute(DateTime value)
取得時間日期的分鐘。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | 時間日期 | — | The date and time. |
返回
| 結果 | 整數 |
過載 2/2
分(值: TimeOnly) -> 整數
int Minute(TimeOnly value)
取得時刻的分鐘。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | TimeOnly | — | The time of day. |
返回
| 結果 | 整數 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
分鐘數
函數取得時間間隔的分鐘部分,即去掉整小時後剩下的部分;要得到整個時間間隔摺合的分鐘數,請用“總分鐘數”。
分鐘數(值: TimeSpan) -> 整數
int Minutes(TimeSpan value)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | TimeSpan | — | The duration. |
返回
| 結果 | 整數 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
月
函數過載 1/2
月(值: 時間日期) -> 整數
int Month(DateTime value)
取得時間日期的月份。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | 時間日期 | — | The date and time. |
返回
| 結果 | 整數 |
過載 2/2
月(值: DateOnly) -> 整數
int Month(DateOnly value)
取得日期的月份。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | DateOnly | — | The date. |
返回
| 結果 | 整數 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
乘以
函數把時間間隔乘以一個倍數,例如求它的三倍或一半。
乘以(值: TimeSpan, 係數: 數字) -> TimeSpan
TimeSpan Multiply(TimeSpan value, double factor)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | TimeSpan | — | The duration to scale. |
| 係數 | 數字 | — | The multiplier, which may be fractional or negative; NaN throws an System.ArgumentException. |
返回
| 結果 | TimeSpan |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
納秒
函數過載 1/2
納秒(值: 時間日期) -> 整數
int Nanosecond(DateTime value)
取得時間日期的納秒部分。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | 時間日期 | — | The date and time. |
返回
| 結果 | 整數 |
過載 2/2
納秒(值: TimeOnly) -> 整數
int Nanosecond(TimeOnly value)
取得時刻的納秒部分。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | TimeOnly | — | The time of day. |
返回
| 結果 | 整數 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
納秒數
函數取得時間間隔的納秒部分,即去掉整微秒後剩下的部分。
納秒數(值: TimeSpan) -> 整數
int Nanoseconds(TimeSpan value)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | TimeSpan | — | The duration. |
返回
| 結果 | 整數 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
取反
函數取時間間隔的相反數:5 分鐘變成 -5 分鐘,反之亦然。
取反(值: TimeSpan) -> TimeSpan
TimeSpan Negate(TimeSpan value)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | TimeSpan | — | The duration to negate; TimeSpan.MinValue throws an System.OverflowException because its negation does not fit. |
返回
| 結果 | TimeSpan |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
不相等
函數過載 1/4
不相等(左側: 時間日期, 右側: 時間日期) -> 真否
bool NotEquals(DateTime left, DateTime right)
檢查兩個時間日期是否不同。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 左側 | 時間日期 | — | The first date and time. |
| 右側 | 時間日期 | — | The second date and time. |
返回
| 結果 | 真否 |
備註
Only the tick values are compared and DateTime.Kind is ignored.
過載 2/4
不相等(左側: DateOnly, 右側: DateOnly) -> 真否
bool NotEquals(DateOnly left, DateOnly right)
檢查兩個日期是否不是同一天。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 左側 | DateOnly | — | The first date. |
| 右側 | DateOnly | — | The second date. |
返回
| 結果 | 真否 |
過載 3/4
不相等(左側: TimeOnly, 右側: TimeOnly) -> 真否
bool NotEquals(TimeOnly left, TimeOnly right)
檢查兩個時刻是否不同。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 左側 | TimeOnly | — | The first time of day. |
| 右側 | TimeOnly | — | The second time of day. |
返回
| 結果 | 真否 |
過載 4/4
不相等(左側: TimeSpan, 右側: TimeSpan) -> 真否
bool NotEquals(TimeSpan left, TimeSpan right)
檢查兩個時間間隔的長度是否不同。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 左側 | TimeSpan | — | The first duration. |
| 右側 | TimeSpan | — | The second duration. |
返回
| 結果 | 真否 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
解析時間日期
函數過載 1/3
解析時間日期(文字: 文字) -> 時間日期
DateTime Parse(string s)
把文字解析為時間日期。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 文字 | 文字 | — |
返回
| 結果 | 時間日期 |
過載 2/3
解析時間日期(文字: 文字, 提供者: IFormatProvider) -> 時間日期
DateTime Parse(string s, IFormatProvider provider)
按給定區域的寫法從文字中讀取時間日期。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 文字 | 文字 | — | The text to read; null throws an System.ArgumentNullException and text that is not a date and time throws a System.FormatException. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
返回
| 結果 | 時間日期 |
過載 3/3
解析時間日期 -> 時間日期
文字: 文字
提供者: IFormatProvider
樣式: DateTimeStylesDateTime Parse(
string s,
IFormatProvider provider,
DateTimeStyles styles)按給定區域的寫法從文字中讀取時間日期,可設定如何處理空白和時區。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 文字 | 文字 | — | The text to read; null throws an System.ArgumentNullException and text that is not a date and time throws a System.FormatException. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
| 樣式 | DateTimeStyles | — | Options such as DateTimeStyles.AdjustToUniversal or DateTimeStyles.AssumeUniversal; a contradictory combination throws an System.ArgumentException. |
返回
| 結果 | 時間日期 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
解析日期
函數過載 1/3
解析日期(文字: 文字) -> DateOnly
DateOnly ParseDateOnly(string s)
把文字解析為日期。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 文字 | 文字 | — |
返回
| 結果 | DateOnly |
過載 2/3
解析日期(文字: 文字, 提供者: IFormatProvider) -> DateOnly
DateOnly ParseDateOnly(string s, IFormatProvider provider)
按給定區域的寫法從文字中讀取日期;文字中不能含有時刻。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 文字 | 文字 | — | The text to read; null throws an System.ArgumentNullException and text that is not a date, or that includes a time, throws a System.FormatException. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
返回
| 結果 | DateOnly |
過載 3/3
解析日期 -> DateOnly
文字: 文字
提供者: IFormatProvider
樣式: DateTimeStylesDateOnly ParseDateOnly(
string s,
IFormatProvider provider,
DateTimeStyles styles)按給定區域的寫法從文字中讀取日期,可設定如何處理空白。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 文字 | 文字 | — | The text to read; null throws an System.ArgumentNullException and text that is not a date, or that includes a time, throws a System.FormatException. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
| 樣式 | DateTimeStyles | — | White-space options only, such as DateTimeStyles.AllowWhiteSpaces; any other style throws an System.ArgumentException. |
返回
| 結果 | DateOnly |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
按格式解析時間日期
函數過載 1/3
按格式解析時間日期 -> 時間日期
文字: 文字
格式: 文字
提供者: IFormatProviderDateTime ParseExact(
string s,
string format,
IFormatProvider provider)從必須完全符合某一格式(如 "yyyy-MM-dd HH:mm:ss")的文字中讀取時間日期。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 文字 | 文字 | — | The text to read; null throws an System.ArgumentNullException and text that does not match the format throws a System.FormatException. |
| 格式 | 文字 | — | The standard or custom format the text must match. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
返回
| 結果 | 時間日期 |
過載 2/3
按格式解析時間日期 -> 時間日期
文字: 文字
格式: 文字
提供者: IFormatProvider
樣式: DateTimeStylesDateTime ParseExact(
string s,
string format,
IFormatProvider provider,
DateTimeStyles styles)從必須完全符合某一格式的文字中讀取時間日期,可設定如何處理空白和時區。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 文字 | 文字 | — | The text to read; null throws an System.ArgumentNullException and text that does not match the format throws a System.FormatException. |
| 格式 | 文字 | — | The standard or custom format the text must match. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
| 樣式 | DateTimeStyles | — | Options such as DateTimeStyles.AllowWhiteSpaces or DateTimeStyles.AssumeUniversal; a contradictory combination throws an System.ArgumentException. |
返回
| 結果 | 時間日期 |
過載 3/3
按格式解析時間日期 -> 時間日期
文字: 文字
格式: 文字陣列
提供者: IFormatProvider
樣式: DateTimeStylesDateTime ParseExact(
string s,
string[] formats,
IFormatProvider provider,
DateTimeStyles styles)從必須完全符合若干格式之一的文字中讀取時間日期,適用於輸入有多種排布的情況。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 文字 | 文字 | — | The text to read; null throws an System.ArgumentNullException and text that matches none of the formats throws a System.FormatException. |
| 格式 | 文字陣列 | — | The formats to try; the first that matches is used. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
| 樣式 | DateTimeStyles | — | Options such as DateTimeStyles.AllowWhiteSpaces or DateTimeStyles.AssumeUniversal; a contradictory combination throws an System.ArgumentException. |
返回
| 結果 | 時間日期 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
按格式解析日期
函數過載 1/3
按格式解析日期 -> DateOnly
文字: 文字
格式: 文字
提供者: IFormatProviderDateOnly ParseExactDateOnly(
string s,
string format,
IFormatProvider provider)從必須完全符合某一格式(如 "yyyy-MM-dd")的文字中讀取日期。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 文字 | 文字 | — | The text to read; null throws an System.ArgumentNullException and text that does not match the format throws a System.FormatException. |
| 格式 | 文字 | — | The standard or custom date format the text must match. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
返回
| 結果 | DateOnly |
過載 2/3
按格式解析日期 -> DateOnly
文字: 文字
格式: 文字
提供者: IFormatProvider
樣式: DateTimeStylesDateOnly ParseExactDateOnly(
string s,
string format,
IFormatProvider provider,
DateTimeStyles styles)從必須完全符合某一格式的文字中讀取日期,可設定如何處理空白。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 文字 | 文字 | — | The text to read; null throws an System.ArgumentNullException and text that does not match the format throws a System.FormatException. |
| 格式 | 文字 | — | The standard or custom date format the text must match. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
| 樣式 | DateTimeStyles | — | White-space options only, such as DateTimeStyles.AllowWhiteSpaces; any other style throws an System.ArgumentException. |
返回
| 結果 | DateOnly |
過載 3/3
按格式解析日期 -> DateOnly
文字: 文字
格式: 文字陣列
提供者: IFormatProvider
樣式: DateTimeStylesDateOnly ParseExactDateOnly(
string s,
string[] formats,
IFormatProvider provider,
DateTimeStyles styles)從必須完全符合若干格式之一的文字中讀取日期,適用於輸入有多種排布的情況。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 文字 | 文字 | — | The text to read; null throws an System.ArgumentNullException and text that matches none of the formats throws a System.FormatException. |
| 格式 | 文字陣列 | — | The date formats to try; the first that matches is used. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
| 樣式 | DateTimeStyles | — | White-space options only, such as DateTimeStyles.AllowWhiteSpaces; any other style throws an System.ArgumentException. |
返回
| 結果 | DateOnly |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
按格式解析時刻
函數過載 1/3
按格式解析時刻 -> TimeOnly
文字: 文字
格式: 文字
提供者: IFormatProviderTimeOnly ParseExactTimeOnly(
string s,
string format,
IFormatProvider provider)從必須完全符合某一格式(如 "HH:mm:ss")的文字中讀取時刻。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 文字 | 文字 | — | The text to read; null throws an System.ArgumentNullException and text that does not match the format throws a System.FormatException. |
| 格式 | 文字 | — | The standard or custom time format the text must match. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
返回
| 結果 | TimeOnly |
過載 2/3
按格式解析時刻 -> TimeOnly
文字: 文字
格式: 文字
提供者: IFormatProvider
樣式: DateTimeStylesTimeOnly ParseExactTimeOnly(
string s,
string format,
IFormatProvider provider,
DateTimeStyles styles)從必須完全符合某一格式的文字中讀取時刻,可設定如何處理空白。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 文字 | 文字 | — | The text to read; null throws an System.ArgumentNullException and text that does not match the format throws a System.FormatException. |
| 格式 | 文字 | — | The standard or custom time format the text must match. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
| 樣式 | DateTimeStyles | — | White-space options only, such as DateTimeStyles.AllowWhiteSpaces; any other style throws an System.ArgumentException. |
返回
| 結果 | TimeOnly |
過載 3/3
按格式解析時刻 -> TimeOnly
文字: 文字
格式: 文字陣列
提供者: IFormatProvider
樣式: DateTimeStylesTimeOnly ParseExactTimeOnly(
string s,
string[] formats,
IFormatProvider provider,
DateTimeStyles styles)從必須完全符合若干格式之一的文字中讀取時刻,適用於輸入有多種排布的情況。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 文字 | 文字 | — | The text to read; null throws an System.ArgumentNullException and text that matches none of the formats throws a System.FormatException. |
| 格式 | 文字陣列 | — | The time formats to try; the first that matches is used. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
| 樣式 | DateTimeStyles | — | White-space options only, such as DateTimeStyles.AllowWhiteSpaces; any other style throws an System.ArgumentException. |
返回
| 結果 | TimeOnly |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
按格式解析時間間隔
函數過載 1/4
按格式解析時間間隔 -> TimeSpan
輸入: 文字
格式: 文字
提供者: IFormatProviderTimeSpan ParseExactTimeSpan(
string input,
string format,
IFormatProvider provider)從必須完全符合某一格式(如 "c" 或 @"hh\:mm" 這樣的自訂格式)的文字中讀取時間間隔。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 輸入 | 文字 | — | The text to read; null throws an System.ArgumentNullException, text that does not match throws a System.FormatException, and a value beyond the System.TimeSpan range throws an System.OverflowException. |
| 格式 | 文字 | — | The standard or custom format the text must match. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
返回
| 結果 | TimeSpan |
過載 2/4
按格式解析時間間隔 -> TimeSpan
輸入: 文字
格式: 文字
提供者: IFormatProvider
樣式: TimeSpanStylesTimeSpan ParseExactTimeSpan(
string input,
string format,
IFormatProvider provider,
TimeSpanStyles styles)從必須完全符合某一格式的文字中讀取時間間隔,可選擇將其視為負值。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 輸入 | 文字 | — | The text to read; null throws an System.ArgumentNullException, text that does not match throws a System.FormatException, and a value beyond the System.TimeSpan range throws an System.OverflowException. |
| 格式 | 文字 | — | The standard or custom format the text must match. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
| 樣式 | TimeSpanStyles | — | TimeSpanStyles.AssumeNegative makes a custom-format result negative; TimeSpanStyles.None leaves it as written. |
返回
| 結果 | TimeSpan |
過載 3/4
按格式解析時間間隔 -> TimeSpan
輸入: 文字
格式: 文字陣列
提供者: IFormatProviderTimeSpan ParseExactTimeSpan(
string input,
string[] formats,
IFormatProvider provider)從必須完全符合若干格式之一的文字中讀取時間間隔,適用於輸入有多種排布的情況。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 輸入 | 文字 | — | The text to read; null throws an System.ArgumentNullException, text that matches none of the formats throws a System.FormatException, and a value beyond the System.TimeSpan range throws an System.OverflowException. |
| 格式 | 文字陣列 | — | The formats to try; the first that matches is used. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
返回
| 結果 | TimeSpan |
過載 4/4
按格式解析時間間隔 -> TimeSpan
輸入: 文字
格式: 文字陣列
提供者: IFormatProvider
樣式: TimeSpanStylesTimeSpan ParseExactTimeSpan(
string input,
string[] formats,
IFormatProvider provider,
TimeSpanStyles styles)從必須完全符合若干格式之一的文字中讀取時間間隔,可選擇將其視為負值。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 輸入 | 文字 | — | The text to read; null throws an System.ArgumentNullException, text that matches none of the formats throws a System.FormatException, and a value beyond the System.TimeSpan range throws an System.OverflowException. |
| 格式 | 文字陣列 | — | The formats to try; the first that matches is used. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
| 樣式 | TimeSpanStyles | — | TimeSpanStyles.AssumeNegative makes a custom-format result negative; TimeSpanStyles.None leaves it as written. |
返回
| 結果 | TimeSpan |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
解析時刻
函數過載 1/3
解析時刻(文字: 文字) -> TimeOnly
TimeOnly ParseTimeOnly(string s)
把文字解析為時刻。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 文字 | 文字 | — |
返回
| 結果 | TimeOnly |
過載 2/3
解析時刻(文字: 文字, 提供者: IFormatProvider) -> TimeOnly
TimeOnly ParseTimeOnly(string s, IFormatProvider provider)
按給定區域的寫法從文字中讀取時刻;文字中不能含有日期。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 文字 | 文字 | — | The text to read; null throws an System.ArgumentNullException and text that is not a time, or that includes a date, throws a System.FormatException. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
返回
| 結果 | TimeOnly |
過載 3/3
解析時刻 -> TimeOnly
文字: 文字
提供者: IFormatProvider
樣式: DateTimeStylesTimeOnly ParseTimeOnly(
string s,
IFormatProvider provider,
DateTimeStyles styles)按給定區域的寫法從文字中讀取時刻,可設定如何處理空白。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 文字 | 文字 | — | The text to read; null throws an System.ArgumentNullException and text that is not a time, or that includes a date, throws a System.FormatException. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
| 樣式 | DateTimeStyles | — | White-space options only, such as DateTimeStyles.AllowWhiteSpaces; any other style throws an System.ArgumentException. |
返回
| 結果 | TimeOnly |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
解析時間間隔
函數過載 1/2
解析時間間隔(文字: 文字) -> TimeSpan
TimeSpan ParseTimeSpan(string s)
把文字解析為時間間隔。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 文字 | 文字 | — |
返回
| 結果 | TimeSpan |
過載 2/2
解析時間間隔(文字: 文字, 提供者: IFormatProvider) -> TimeSpan
TimeSpan ParseTimeSpan(string s, IFormatProvider provider)
從形如 [-][d.]hh:mm[:ss[.fffffff]] 的文字中讀取時間間隔,例如 "1.02:30:00" 表示一天兩個半小時,小數點按給定區域的寫法。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 文字 | 文字 | — | The text to read; null throws an System.ArgumentNullException, text in the wrong form throws a System.FormatException, and a part out of range (such as 24 hours) or a total beyond the System.TimeSpan range throws an System.OverflowException. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
返回
| 結果 | TimeSpan |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
秒
函數過載 1/2
秒(值: 時間日期) -> 整數
int Second(DateTime value)
取得時間日期的秒。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | 時間日期 | — | The date and time. |
返回
| 結果 | 整數 |
過載 2/2
秒(值: TimeOnly) -> 整數
int Second(TimeOnly value)
取得時刻的秒。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | TimeOnly | — | The time of day. |
返回
| 結果 | 整數 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
秒數
函數取得時間間隔的秒部分,即去掉整分鐘後剩下的部分;要得到整個時間間隔摺合的秒數,請用“總秒數”。
秒數(值: TimeSpan) -> 整數
int Seconds(TimeSpan value)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | TimeSpan | — | The duration. |
返回
| 結果 | 整數 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
指定時間種類
函數建立一個計時週期與給定值相同、但時間型別為指定型別的新時間日期。
指定時間種類(值: 時間日期, 種類: DateTimeKind) -> 時間日期
DateTime SpecifyKind(DateTime value, DateTimeKind kind)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | 時間日期 | — | |
| 種類 | DateTimeKind | — |
返回
| 結果 | 時間日期 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
減去
函數過載 1/4
減去(左側: 時間日期, 右側: 時間日期) -> TimeSpan
TimeSpan Subtract(DateTime left, DateTime right)
計算從一個時間日期到另一個經過的時間。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 左側 | 時間日期 | — | The later date and time. |
| 右側 | 時間日期 | — | The earlier date and time. |
返回
| 結果 | TimeSpan |
備註
The tick values are subtracted directly and DateTime.Kind is ignored, so convert both values to UTC first if one is local and the other UTC.
過載 2/4
減去(值: 時間日期, 增量: TimeSpan) -> 時間日期
DateTime Subtract(DateTime value, TimeSpan delta)
把時間日期提前一段時間間隔。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | 時間日期 | — | The starting date and time; its kind is kept. |
| 增量 | TimeSpan | — | The duration to subtract; a negative duration moves forward. |
返回
| 結果 | 時間日期 |
過載 3/4
減去(左側: TimeOnly, 右側: TimeOnly) -> TimeSpan
TimeSpan Subtract(TimeOnly left, TimeOnly right)
計算鐘錶從一個時刻向前走到另一個時刻需要多久,必要時越過午夜。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 左側 | TimeOnly | — | The time of day to reach. |
| 右側 | TimeOnly | — | The time of day to start from. |
返回
| 結果 | TimeSpan |
備註
The result is never negative: from 23:00 to 01:00 is 2 hours, not -22 hours.
過載 4/4
減去(左側: TimeSpan, 右側: TimeSpan) -> TimeSpan
TimeSpan Subtract(TimeSpan left, TimeSpan right)
從一個時間間隔中減去另一個。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 左側 | TimeSpan | — | The duration to subtract from. |
| 右側 | TimeSpan | — | The duration to subtract. |
返回
| 結果 | TimeSpan |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
計時週期數
函數過載 1/3
計時週期數(值: 時間日期) -> 大整數
long Ticks(DateTime value)
把時間日期表示為一個計時週期數,便於儲存或做精確運算。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | 時間日期 | — | The date and time. |
返回
| 結果 | 大整數 |
過載 2/3
計時週期數(值: TimeOnly) -> 大整數
long Ticks(TimeOnly value)
把時刻表示為自午夜起的計時週期數。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | TimeOnly | — | The time of day. |
返回
| 結果 | 大整數 |
過載 3/3
計時週期數(值: TimeSpan) -> 大整數
long Ticks(TimeSpan value)
把時間間隔表示為一個計時週期數,便於儲存或做精確運算。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | TimeSpan | — | The duration. |
返回
| 結果 | 大整數 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
相隔時間
函數計算從一個日期到另一個日期的時間,結果是以整天計的時間間隔。
相隔時間(左側: DateOnly, 右側: DateOnly) -> TimeSpan
TimeSpan TimeBetween(DateOnly left, DateOnly right)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 左側 | DateOnly | — | The later date. |
| 右側 | DateOnly | — | The earlier date. |
返回
| 結果 | TimeSpan |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
一天中的時刻
函數取得時間日期的時刻,表示為自午夜起的時間間隔。
一天中的時刻(值: 時間日期) -> TimeSpan
TimeSpan TimeOfDay(DateTime value)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | 時間日期 | — | The date and time. |
返回
| 結果 | TimeSpan |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
從時間日期取時刻
函數取時間日期的時刻,去掉其日期。
從時間日期取時刻(值: 時間日期) -> TimeOnly
TimeOnly TimeOnlyFromDateTime(DateTime value)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | 時間日期 | — | The date and time to take the time of day from; its kind is ignored and no time-zone conversion is made. |
返回
| 結果 | TimeOnly |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
從計時週期數取時刻
函數用自午夜起的計時週期數建立時刻。
從計時週期數取時刻(計時週期數: 大整數) -> TimeOnly
TimeOnly TimeOnlyFromTicks(long ticks)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 計時週期數 | 大整數 | — | The number of 100-nanosecond ticks since midnight, from 0 to one less than TimeSpan.TicksPerDay; any other value throws an System.ArgumentOutOfRangeException. |
返回
| 結果 | TimeOnly |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
從時間間隔取時刻
函數把自午夜起的時間間隔轉換為時刻,例如把 13 小時轉換為 13:00。
從時間間隔取時刻(值: TimeSpan) -> TimeOnly
TimeOnly TimeOnlyFromTimeSpan(TimeSpan value)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | TimeSpan | — | The time elapsed since midnight; must be at least zero and less than one day, otherwise an System.ArgumentOutOfRangeException is thrown. |
返回
| 結果 | TimeOnly |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
由天數生成時間間隔
函數用天數建立時間間隔,天數可以是小數或負數(1.5 即一天半)。
由天數生成時間間隔(天數: 數字) -> TimeSpan
TimeSpan TimeSpanFromDays(double days)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 天數 | 數字 | — | The number of days; NaN throws an System.ArgumentException and a value beyond the System.TimeSpan range throws an System.OverflowException. |
返回
| 結果 | TimeSpan |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
由小時數生成時間間隔
函數用小時數建立時間間隔,可以是小數或負數。
由小時數生成時間間隔(小時數: 數字) -> TimeSpan
TimeSpan TimeSpanFromHours(double hours)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 小時數 | 數字 | — | The number of hours; NaN throws an System.ArgumentException and a value beyond the System.TimeSpan range throws an System.OverflowException. |
返回
| 結果 | TimeSpan |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
由微秒數生成時間間隔
函數用微秒數建立時間間隔,可以是小數或負數。
由微秒數生成時間間隔(微秒數: 數字) -> TimeSpan
TimeSpan TimeSpanFromMicroseconds(double microseconds)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 微秒數 | 數字 | — | The number of microseconds; NaN throws an System.ArgumentException and a value beyond the System.TimeSpan range throws an System.OverflowException. |
返回
| 結果 | TimeSpan |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
由毫秒數生成時間間隔
函數用毫秒數建立時間間隔,可以是小數或負數。
由毫秒數生成時間間隔(毫秒數: 數字) -> TimeSpan
TimeSpan TimeSpanFromMilliseconds(double milliseconds)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 毫秒數 | 數字 | — | The number of milliseconds; NaN throws an System.ArgumentException and a value beyond the System.TimeSpan range throws an System.OverflowException. |
返回
| 結果 | TimeSpan |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
由分鐘數生成時間間隔
函數用分鐘數建立時間間隔,可以是小數或負數。
由分鐘數生成時間間隔(分鐘數: 數字) -> TimeSpan
TimeSpan TimeSpanFromMinutes(double minutes)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 分鐘數 | 數字 | — | The number of minutes; NaN throws an System.ArgumentException and a value beyond the System.TimeSpan range throws an System.OverflowException. |
返回
| 結果 | TimeSpan |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
由秒數生成時間間隔
函數用秒數建立時間間隔,可以是小數或負數。
由秒數生成時間間隔(秒數: 數字) -> TimeSpan
TimeSpan TimeSpanFromSeconds(double seconds)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 秒數 | 數字 | — | The number of seconds; NaN throws an System.ArgumentException and a value beyond the System.TimeSpan range throws an System.OverflowException. |
返回
| 結果 | TimeSpan |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
由計時週期數生成時間間隔
函數用計時週期數建立時間間隔,一個計時週期為 100 納秒。
由計時週期數生成時間間隔(計時週期數: 大整數) -> TimeSpan
TimeSpan TimeSpanFromTicks(long ticks)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 計時週期數 | 大整數 | — | The number of ticks; may be negative. |
返回
| 結果 | TimeSpan |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
時間間隔轉為時刻
函數把自午夜起的時間間隔轉換為時刻,例如把 13 小時轉換為 13:00。
時間間隔轉為時刻(值: TimeSpan) -> TimeOnly
TimeOnly TimeSpanToTimeOnly(TimeSpan value)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | TimeSpan | — | The time elapsed since midnight; must be at least zero and less than one day, otherwise an System.ArgumentOutOfRangeException is thrown. |
返回
| 結果 | TimeOnly |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
轉為二進位制值
函數把時間日期連同其時間型別打包成一個 64 位數字以便儲存;“從二進位制值還原”可把它還原。
轉為二進位制值(值: 時間日期) -> 大整數
long ToBinary(DateTime value)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | 時間日期 | — | The date and time to pack. |
返回
| 結果 | 大整數 |
備註
A local value is stored as its UTC instant, so restoring it on a machine in another time zone gives the same moment in that machine's local time.
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
轉為日期
函數取時間日期的日曆日期,去掉其時刻。
轉為日期(值: 時間日期) -> DateOnly
DateOnly ToDateOnly(DateTime value)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | 時間日期 | — | The date and time to take the date from; its kind is ignored and no time-zone conversion is made. |
返回
| 結果 | DateOnly |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
轉為時間日期
函數過載 1/2
轉為時間日期(日期: DateOnly, 時間: TimeOnly) -> 時間日期
DateTime ToDateTime(DateOnly date, TimeOnly time)
把一個日期和一個時刻合成一個時間日期。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 日期 | DateOnly | — | The calendar date. |
| 時間 | TimeOnly | — | The time of day on that date. |
返回
| 結果 | 時間日期 |
過載 2/2
轉為時間日期 -> 時間日期
日期: DateOnly
時間: TimeOnly
種類: DateTimeKindDateTime ToDateTime(
DateOnly date,
TimeOnly time,
DateTimeKind kind)把一個日期和一個時刻合成一個時間日期,並標為本地時間、UTC 或未指定。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 日期 | DateOnly | — | The calendar date. |
| 時間 | TimeOnly | — | The time of day on that date. |
| 種類 | DateTimeKind | — | Whether the result is local time, UTC or unspecified. |
返回
| 結果 | 時間日期 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
轉為檔案時間
函數把時間日期轉換為 Windows 檔案時間:自 1601-01-01 00:00:00 UTC 起經過的 100 納秒間隔數。
轉為檔案時間(值: 時間日期) -> 大整數
long ToFileTime(DateTime value)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | 時間日期 | — | The date and time; a local or unspecified value is treated as local time and converted to UTC first. |
返回
| 結果 | 大整數 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
轉為 UTC 檔案時間
函數把時間日期轉換為 Windows 檔案時間,未指定型別的值視為已是 UTC。
轉為 UTC 檔案時間(值: 時間日期) -> 大整數
long ToFileTimeUtc(DateTime value)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | 時間日期 | — | The date and time; only a local value is converted to UTC first, while UTC and unspecified values are used as they are. |
返回
| 結果 | 大整數 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
轉為本地時間
函數把時間日期轉換為本地時間。
轉為本地時間(值: 時間日期) -> 時間日期
DateTime ToLocalTime(DateTime value)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | 時間日期 | — |
返回
| 結果 | 時間日期 |
備註
DateTime.ToLocalTime uses the DateTime.Kind value:
DateTimeKind.Utc is converted to local time, DateTimeKind.Local
is returned unchanged, and DateTimeKind.Unspecified is assumed to be UTC before conversion.
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
轉為長日期文字
函數過載 1/2
轉為長日期文字(值: 時間日期) -> 文字
string ToLongDateString(DateTime value)
按目前區域的長日期模式寫出時間日期中的日期,例如美式英語中的 Saturday, June 15, 2024。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | 時間日期 | — | The date and time; its time of day is not shown. |
返回
| 結果 | 文字 |
過載 2/2
轉為長日期文字(值: DateOnly) -> 文字
string ToLongDateString(DateOnly value)
按目前區域的長日期模式寫出日期,例如美式英語中的 Saturday, June 15, 2024。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | DateOnly | — | The date to format. |
返回
| 結果 | 文字 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
轉為長時間文字
函數過載 1/2
轉為長時間文字(值: 時間日期) -> 文字
string ToLongTimeString(DateTime value)
按目前區域的長時間模式寫出時間日期中的時間,通常包含時、分、秒。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | 時間日期 | — | The date and time; its date is not shown. |
返回
| 結果 | 文字 |
過載 2/2
轉為長時間文字(值: TimeOnly) -> 文字
string ToLongTimeString(TimeOnly value)
按目前區域的長時間模式寫出時刻,通常包含時、分、秒。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | TimeOnly | — | The time of day to format. |
返回
| 結果 | 文字 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
轉為 OLE 自動化日期
函數把時間日期轉換為 OLE 自動化日期,即 Excel 等 Office 應用表示日期所用的數字格式。
轉為 OLE 自動化日期(值: 時間日期) -> 數字
double ToOADate(DateTime value)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | 時間日期 | — | The date and time; DateTime.MinValue gives 0, and other dates before year 100 throw an System.OverflowException. |
返回
| 結果 | 數字 |
備註
The whole part counts days from 1899-12-30 and the fraction is the time of day, so 1.5 is 1899-12-31 12:00. The kind is ignored.
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
轉為短日期文字
函數過載 1/2
轉為短日期文字(值: 時間日期) -> 文字
string ToShortDateString(DateTime value)
按目前區域的短日期模式寫出時間日期中的日期,例如美式英語中的 6/15/2024。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | 時間日期 | — | The date and time; its time of day is not shown. |
返回
| 結果 | 文字 |
過載 2/2
轉為短日期文字(值: DateOnly) -> 文字
string ToShortDateString(DateOnly value)
按目前區域的短日期模式寫出日期,例如美式英語中的 6/15/2024。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | DateOnly | — | The date to format. |
返回
| 結果 | 文字 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
轉為短時間文字
函數過載 1/2
轉為短時間文字(值: 時間日期) -> 文字
string ToShortTimeString(DateTime value)
按目前區域的短時間模式寫出時間日期中的時間,通常包含時和分。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | 時間日期 | — | The date and time; its date is not shown. |
返回
| 結果 | 文字 |
過載 2/2
轉為短時間文字(值: TimeOnly) -> 文字
string ToShortTimeString(TimeOnly value)
按目前區域的短時間模式寫出時刻,通常包含時和分。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | TimeOnly | — | The time of day to format. |
返回
| 結果 | 文字 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
轉為文字
函數過載 1/15
轉為文字(值: 時間日期) -> 文字
string ToString(DateTime value)
把時間日期轉換為文字。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | 時間日期 | — |
返回
| 結果 | 文字 |
過載 2/15
轉為文字(值: 時間日期, 格式: 文字) -> 文字
string ToString(DateTime value, string format)
用某一格式把時間日期寫成文字(不隨機器的區域改變),格式如 "yyyy-MM-dd HH:mm",或標準格式說明符,如表示可往返 ISO 8601 的 "o"。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | 時間日期 | — | The date and time to format. |
| 格式 | 文字 | — | A standard or custom date and time format string; null or empty uses the general "G" format, and an invalid one throws a System.FormatException. |
返回
| 結果 | 文字 |
過載 3/15
轉為文字(值: 時間日期, 提供者: IFormatProvider) -> 文字
string ToString(DateTime value, IFormatProvider provider)
按給定區域的常規“G”格式把時間日期寫成文字。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | 時間日期 | — | The date and time to format. |
| 提供者 | IFormatProvider | — | The culture whose conventions to use, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
返回
| 結果 | 文字 |
過載 4/15
轉為文字 -> 文字
值: 時間日期
格式: 文字
提供者: IFormatProviderstring ToString(
DateTime value,
string format,
IFormatProvider provider)按某一格式和給定區域的習慣把時間日期寫成文字。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | 時間日期 | — | The date and time to format. |
| 格式 | 文字 | — | A standard or custom date and time format string; null or empty uses the general "G" format, and an invalid one throws a System.FormatException. |
| 提供者 | IFormatProvider | — | The culture whose conventions to use, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
返回
| 結果 | 文字 |
過載 5/15
轉為文字(值: DateOnly) -> 文字
string ToString(DateOnly value)
把日期轉換為文字。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | DateOnly | — |
返回
| 結果 | 文字 |
過載 6/15
轉為文字(值: DateOnly, 格式: 文字) -> 文字
string ToString(DateOnly value, string format)
用某一格式把日期寫成文字(不隨機器的區域改變),格式如 "yyyy-MM-dd",或表示 ISO 8601 的 "o"。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | DateOnly | — | The date to format. |
| 格式 | 文字 | — | A standard or custom date format string; null or empty uses the short date "d" format, and an invalid one or one that asks for a time part throws a System.FormatException. |
返回
| 結果 | 文字 |
過載 7/15
轉為文字(值: DateOnly, 提供者: IFormatProvider) -> 文字
string ToString(DateOnly value, IFormatProvider provider)
按給定區域的短日期模式把日期寫成文字。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | DateOnly | — | The date to format. |
| 提供者 | IFormatProvider | — | The culture whose conventions to use, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
返回
| 結果 | 文字 |
過載 8/15
轉為文字 -> 文字
值: DateOnly
格式: 文字
提供者: IFormatProviderstring ToString(
DateOnly value,
string format,
IFormatProvider provider)按某一格式和給定區域的習慣把日期寫成文字。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | DateOnly | — | The date to format. |
| 格式 | 文字 | — | A standard or custom date format string; null or empty uses the short date "d" format, and an invalid one or one that asks for a time part throws a System.FormatException. |
| 提供者 | IFormatProvider | — | The culture whose conventions to use, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
返回
| 結果 | 文字 |
過載 9/15
轉為文字(值: TimeOnly) -> 文字
string ToString(TimeOnly value)
把時刻轉換為文字。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | TimeOnly | — |
返回
| 結果 | 文字 |
過載 10/15
轉為文字(值: TimeOnly, 格式: 文字) -> 文字
string ToString(TimeOnly value, string format)
用某一格式把時刻寫成文字(不隨機器的區域改變),格式如 "HH:mm:ss",或表示 ISO 8601 的 "o"。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | TimeOnly | — | The time of day to format. |
| 格式 | 文字 | — | A standard or custom time format string; null or empty uses the short time "t" format, and an invalid one or one that asks for a date part throws a System.FormatException. |
返回
| 結果 | 文字 |
過載 11/15
轉為文字(值: TimeOnly, 提供者: IFormatProvider) -> 文字
string ToString(TimeOnly value, IFormatProvider provider)
按給定區域的短時間模式把時刻寫成文字。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | TimeOnly | — | The time of day to format. |
| 提供者 | IFormatProvider | — | The culture whose conventions to use, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
返回
| 結果 | 文字 |
過載 12/15
轉為文字 -> 文字
值: TimeOnly
格式: 文字
提供者: IFormatProviderstring ToString(
TimeOnly value,
string format,
IFormatProvider provider)按某一格式和給定區域的習慣把時刻寫成文字。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | TimeOnly | — | The time of day to format. |
| 格式 | 文字 | — | A standard or custom time format string; null or empty uses the short time "t" format, and an invalid one or one that asks for a date part throws a System.FormatException. |
| 提供者 | IFormatProvider | — | The culture whose conventions to use, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
返回
| 結果 | 文字 |
過載 13/15
轉為文字(值: TimeSpan) -> 文字
string ToString(TimeSpan value)
把時間間隔轉換為文字。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | TimeSpan | — |
返回
| 結果 | 文字 |
過載 14/15
轉為文字(值: TimeSpan, 格式: 文字) -> 文字
string ToString(TimeSpan value, string format)
用某一格式把時間間隔寫成文字:"c" 表示固定的 [-][d.]hh:mm:ss[.fffffff] 形式,"g" 或 "G" 表示隨區域變化的短形式或長形式,也可以是 @"hh\:mm" 這樣的自訂格式。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | TimeSpan | — | The duration to format. |
| 格式 | 文字 | — | The format string; null or empty uses "c", and an invalid one throws a System.FormatException. |
返回
| 結果 | 文字 |
過載 15/15
轉為文字 -> 文字
值: TimeSpan
格式: 文字
提供者: IFormatProviderstring ToString(
TimeSpan value,
string format,
IFormatProvider provider)按某一格式和給定區域的習慣把時間間隔寫成文字,區域會影響 "g" 和 "G" 格式。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | TimeSpan | — | The duration to format. |
| 格式 | 文字 | — | The format string, such as "c", "g", "G" or a custom pattern; null or empty uses "c", and an invalid one throws a System.FormatException. |
| 提供者 | IFormatProvider | — | The culture whose conventions to use, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
返回
| 結果 | 文字 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
總天數
函數取得時間間隔摺合的天數,含小數部分(36 小時即 1.5)。
總天數(值: TimeSpan) -> 數字
double TotalDays(TimeSpan value)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | TimeSpan | — | The duration. |
返回
| 結果 | 數字 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
總小時數
函數取得時間間隔摺合的小時數,含小數部分(90 分鐘即 1.5)。
總小時數(值: TimeSpan) -> 數字
double TotalHours(TimeSpan value)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | TimeSpan | — | The duration. |
返回
| 結果 | 數字 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
總微秒數
函數取得時間間隔摺合的微秒數,含小數部分。
總微秒數(值: TimeSpan) -> 數字
double TotalMicroseconds(TimeSpan value)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | TimeSpan | — | The duration. |
返回
| 結果 | 數字 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
總毫秒數
函數取得時間間隔摺合的毫秒數,含小數部分。
總毫秒數(值: TimeSpan) -> 數字
double TotalMilliseconds(TimeSpan value)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | TimeSpan | — | The duration. |
返回
| 結果 | 數字 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
總分鐘數
函數取得時間間隔摺合的分鐘數,含小數部分。
總分鐘數(值: TimeSpan) -> 數字
double TotalMinutes(TimeSpan value)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | TimeSpan | — | The duration. |
返回
| 結果 | 數字 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
總納秒數
函數取得時間間隔摺合的納秒數。
總納秒數(值: TimeSpan) -> 數字
double TotalNanoseconds(TimeSpan value)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | TimeSpan | — | The duration. |
返回
| 結果 | 數字 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
總秒數
函數取得時間間隔摺合的秒數,含小數部分。
總秒數(值: TimeSpan) -> 數字
double TotalSeconds(TimeSpan value)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | TimeSpan | — | The duration. |
返回
| 結果 | 數字 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
轉為時刻
函數取時間日期的時刻,去掉其日期。
轉為時刻(值: 時間日期) -> TimeOnly
TimeOnly ToTimeOnly(DateTime value)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | 時間日期 | — | The date and time to take the time of day from; its kind is ignored and no time-zone conversion is made. |
返回
| 結果 | TimeOnly |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
轉為時間間隔
函數把時刻轉換為自午夜起的時間間隔,例如把 13:30 轉換為 13 小時 30 分鐘。
轉為時間間隔(值: TimeOnly) -> TimeSpan
TimeSpan ToTimeSpan(TimeOnly value)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | TimeOnly | — | The time of day. |
返回
| 結果 | TimeSpan |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
轉為 UTC 時間
函數把時間日期轉換為協調世界時(UTC)。
轉為 UTC 時間(值: 時間日期) -> 時間日期
DateTime ToUniversalTime(DateTime value)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | 時間日期 | — |
返回
| 結果 | 時間日期 |
備註
DateTime.ToUniversalTime uses the DateTime.Kind value:
DateTimeKind.Local is converted to UTC, DateTimeKind.Utc
is returned unchanged, and DateTimeKind.Unspecified is assumed to be local time before conversion.
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
轉為 Unix 毫秒時間戳
函數把時間日期轉換為毫秒級 Unix 時間戳:自 1970-01-01 00:00:00 UTC 起經過的整毫秒數,JavaScript 和許多 Web API 使用這種形式。
轉為 Unix 毫秒時間戳(值: 時間日期) -> 大整數
long ToUnixTimeMilliseconds(DateTime value)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | 時間日期 | — | The date and time to convert. |
返回
| 結果 | 大整數 |
備註
A UTC value is used as it is; a local or unspecified value is treated as local time and converted to UTC using the local time zone. Times before the epoch give negative numbers, and fractions of a millisecond are discarded.
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
轉為 Unix 秒時間戳
函數把時間日期轉換為 Unix 時間戳:自 1970-01-01 00:00:00 UTC 起經過的整秒數。
轉為 Unix 秒時間戳(值: 時間日期) -> 大整數
long ToUnixTimeSeconds(DateTime value)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | 時間日期 | — | The date and time to convert. |
返回
| 結果 | 大整數 |
備註
A UTC value is used as it is; a local or unspecified value is treated as local time and converted to UTC using the local time zone. Times before the epoch give negative numbers, and fractions of a second are discarded.
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
嘗試解析時間日期
函數過載 1/2
嘗試解析時間日期(文字: 文字) -> (結果: 真否, 結果: 時間日期)
bool TryParse(string s, out DateTime result)
嘗試從文字中讀取時間日期(不隨機器的區域改變),失敗時報告失敗而不是出錯中止。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 文字 | 文字 | — | The text to read; null or unreadable text makes the node report failure. |
返回
| 結果 | 真否 |
| 結果 | 時間日期 |
過載 2/2
嘗試解析時間日期 -> (結果: 真否, 結果: 時間日期)
文字: 文字
提供者: IFormatProvider
樣式: DateTimeStylesbool TryParse(
string s,
IFormatProvider provider,
DateTimeStyles styles,
out DateTime result)嘗試按給定區域的寫法從文字中讀取時間日期,失敗時報告失敗而不是出錯中止。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 文字 | 文字 | — | The text to read; null or unreadable text makes the node report failure. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
| 樣式 | DateTimeStyles | — | Options such as DateTimeStyles.AdjustToUniversal; a contradictory combination still throws an System.ArgumentException. |
返回
| 結果 | 真否 |
| 結果 | 時間日期 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
嘗試解析日期
函數過載 1/2
嘗試解析日期(文字: 文字) -> (結果: 真否, 結果: DateOnly)
bool TryParseDateOnly(string s, out DateOnly result)
嘗試從文字中讀取日期(不隨機器的區域改變),失敗時報告失敗而不是出錯中止。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 文字 | 文字 | — | The text to read; null, unreadable text or text that includes a time makes the node report failure. |
返回
| 結果 | 真否 |
| 結果 | DateOnly |
過載 2/2
嘗試解析日期 -> (結果: 真否, 結果: DateOnly)
文字: 文字
提供者: IFormatProvider
樣式: DateTimeStylesbool TryParseDateOnly(
string s,
IFormatProvider provider,
DateTimeStyles styles,
out DateOnly result)嘗試按給定區域的寫法從文字中讀取日期,失敗時報告失敗而不是出錯中止。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 文字 | 文字 | — | The text to read; null, unreadable text or text that includes a time makes the node report failure. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
| 樣式 | DateTimeStyles | — | White-space options only, such as DateTimeStyles.AllowWhiteSpaces; any other style still throws an System.ArgumentException. |
返回
| 結果 | 真否 |
| 結果 | DateOnly |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
嘗試按格式解析時間日期
函數過載 1/2
嘗試按格式解析時間日期 -> (結果: 真否, 結果: 時間日期)
文字: 文字
格式: 文字
提供者: IFormatProvider
樣式: DateTimeStylesbool TryParseExact(
string s,
string format,
IFormatProvider provider,
DateTimeStyles styles,
out DateTime result)嘗試從必須完全符合某一格式的文字中讀取時間日期,失敗時報告失敗而不是出錯中止。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 文字 | 文字 | — | The text to read; null or text that does not match makes the node report failure. |
| 格式 | 文字 | — | The standard or custom format the text must match; null makes the node report failure. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
| 樣式 | DateTimeStyles | — | Options such as DateTimeStyles.AllowWhiteSpaces; a contradictory combination still throws an System.ArgumentException. |
返回
| 結果 | 真否 |
| 結果 | 時間日期 |
過載 2/2
嘗試按格式解析時間日期 -> (結果: 真否, 結果: 時間日期)
文字: 文字
格式: 文字陣列
提供者: IFormatProvider
樣式: DateTimeStylesbool TryParseExact(
string s,
string[] formats,
IFormatProvider provider,
DateTimeStyles styles,
out DateTime result)嘗試從必須完全符合若干格式之一的文字中讀取時間日期,失敗時報告失敗而不是出錯中止。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 文字 | 文字 | — | The text to read; null or text that matches none of the formats makes the node report failure. |
| 格式 | 文字陣列 | — | The formats to try; the first that matches is used. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
| 樣式 | DateTimeStyles | — | Options such as DateTimeStyles.AllowWhiteSpaces; a contradictory combination still throws an System.ArgumentException. |
返回
| 結果 | 真否 |
| 結果 | 時間日期 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
嘗試按格式解析日期
函數過載 1/2
嘗試按格式解析日期 -> (結果: 真否, 結果: DateOnly)
文字: 文字
格式: 文字
提供者: IFormatProvider
樣式: DateTimeStylesbool TryParseExactDateOnly(
string s,
string format,
IFormatProvider provider,
DateTimeStyles styles,
out DateOnly result)嘗試從必須完全符合某一格式的文字中讀取日期,失敗時報告失敗而不是出錯中止。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 文字 | 文字 | — | The text to read; null or text that does not match makes the node report failure. |
| 格式 | 文字 | — | The standard or custom date format the text must match; null makes the node report failure. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
| 樣式 | DateTimeStyles | — | White-space options only, such as DateTimeStyles.AllowWhiteSpaces; any other style still throws an System.ArgumentException. |
返回
| 結果 | 真否 |
| 結果 | DateOnly |
過載 2/2
嘗試按格式解析日期 -> (結果: 真否, 結果: DateOnly)
文字: 文字
格式: 文字陣列
提供者: IFormatProvider
樣式: DateTimeStylesbool TryParseExactDateOnly(
string s,
string[] formats,
IFormatProvider provider,
DateTimeStyles styles,
out DateOnly result)嘗試從必須完全符合若干格式之一的文字中讀取日期,失敗時報告失敗而不是出錯中止。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 文字 | 文字 | — | The text to read; null or text that matches none of the formats makes the node report failure. |
| 格式 | 文字陣列 | — | The date formats to try; the first that matches is used. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
| 樣式 | DateTimeStyles | — | White-space options only, such as DateTimeStyles.AllowWhiteSpaces; any other style still throws an System.ArgumentException. |
返回
| 結果 | 真否 |
| 結果 | DateOnly |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
嘗試按格式解析時刻
函數過載 1/2
嘗試按格式解析時刻 -> (結果: 真否, 結果: TimeOnly)
文字: 文字
格式: 文字
提供者: IFormatProvider
樣式: DateTimeStylesbool TryParseExactTimeOnly(
string s,
string format,
IFormatProvider provider,
DateTimeStyles styles,
out TimeOnly result)嘗試從必須完全符合某一格式的文字中讀取時刻,失敗時報告失敗而不是出錯中止。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 文字 | 文字 | — | The text to read; null or text that does not match makes the node report failure. |
| 格式 | 文字 | — | The standard or custom time format the text must match; null makes the node report failure. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
| 樣式 | DateTimeStyles | — | White-space options only, such as DateTimeStyles.AllowWhiteSpaces; any other style still throws an System.ArgumentException. |
返回
| 結果 | 真否 |
| 結果 | TimeOnly |
過載 2/2
嘗試按格式解析時刻 -> (結果: 真否, 結果: TimeOnly)
文字: 文字
格式: 文字陣列
提供者: IFormatProvider
樣式: DateTimeStylesbool TryParseExactTimeOnly(
string s,
string[] formats,
IFormatProvider provider,
DateTimeStyles styles,
out TimeOnly result)嘗試從必須完全符合若干格式之一的文字中讀取時刻,失敗時報告失敗而不是出錯中止。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 文字 | 文字 | — | The text to read; null or text that matches none of the formats makes the node report failure. |
| 格式 | 文字陣列 | — | The time formats to try; the first that matches is used. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
| 樣式 | DateTimeStyles | — | White-space options only, such as DateTimeStyles.AllowWhiteSpaces; any other style still throws an System.ArgumentException. |
返回
| 結果 | 真否 |
| 結果 | TimeOnly |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
嘗試按格式解析時間間隔
函數過載 1/4
嘗試按格式解析時間間隔 -> (結果: 真否, 結果: TimeSpan)
輸入: 文字
格式: 文字
提供者: IFormatProviderbool TryParseExactTimeSpan(
string input,
string format,
IFormatProvider provider,
out TimeSpan result)嘗試從必須完全符合某一格式的文字中讀取時間間隔,失敗時報告失敗而不是出錯中止。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 輸入 | 文字 | — | The text to read; null, text that does not match or a value out of range makes the node report failure. |
| 格式 | 文字 | — | The standard or custom format the text must match; null makes the node report failure. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
返回
| 結果 | 真否 |
| 結果 | TimeSpan |
過載 2/4
嘗試按格式解析時間間隔 -> (結果: 真否, 結果: TimeSpan)
輸入: 文字
格式: 文字
提供者: IFormatProvider
樣式: TimeSpanStylesbool TryParseExactTimeSpan(
string input,
string format,
IFormatProvider provider,
TimeSpanStyles styles,
out TimeSpan result)嘗試從必須完全符合某一格式的文字中讀取時間間隔,可選擇將其視為負值,失敗時報告失敗而不是出錯中止。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 輸入 | 文字 | — | The text to read; null, text that does not match or a value out of range makes the node report failure. |
| 格式 | 文字 | — | The standard or custom format the text must match; null makes the node report failure. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
| 樣式 | TimeSpanStyles | — | TimeSpanStyles.AssumeNegative makes a custom-format result negative; TimeSpanStyles.None leaves it as written. |
返回
| 結果 | 真否 |
| 結果 | TimeSpan |
過載 3/4
嘗試按格式解析時間間隔 -> (結果: 真否, 結果: TimeSpan)
輸入: 文字
格式: 文字陣列
提供者: IFormatProviderbool TryParseExactTimeSpan(
string input,
string[] formats,
IFormatProvider provider,
out TimeSpan result)嘗試從必須完全符合若干格式之一的文字中讀取時間間隔,失敗時報告失敗而不是出錯中止。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 輸入 | 文字 | — | The text to read; null, text that matches none of the formats or a value out of range makes the node report failure. |
| 格式 | 文字陣列 | — | The formats to try; the first that matches is used. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
返回
| 結果 | 真否 |
| 結果 | TimeSpan |
過載 4/4
嘗試按格式解析時間間隔 -> (結果: 真否, 結果: TimeSpan)
輸入: 文字
格式: 文字陣列
提供者: IFormatProvider
樣式: TimeSpanStylesbool TryParseExactTimeSpan(
string input,
string[] formats,
IFormatProvider provider,
TimeSpanStyles styles,
out TimeSpan result)嘗試從必須完全符合若干格式之一的文字中讀取時間間隔,可選擇將其視為負值,失敗時報告失敗而不是出錯中止。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 輸入 | 文字 | — | The text to read; null, text that matches none of the formats or a value out of range makes the node report failure. |
| 格式 | 文字陣列 | — | The formats to try; the first that matches is used. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
| 樣式 | TimeSpanStyles | — | TimeSpanStyles.AssumeNegative makes a custom-format result negative; TimeSpanStyles.None leaves it as written. |
返回
| 結果 | 真否 |
| 結果 | TimeSpan |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
嘗試解析時刻
函數過載 1/2
嘗試解析時刻(文字: 文字) -> (結果: 真否, 結果: TimeOnly)
bool TryParseTimeOnly(string s, out TimeOnly result)
嘗試從文字中讀取時刻(不隨機器的區域改變),失敗時報告失敗而不是出錯中止。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 文字 | 文字 | — | The text to read; null, unreadable text or text that includes a date makes the node report failure. |
返回
| 結果 | 真否 |
| 結果 | TimeOnly |
過載 2/2
嘗試解析時刻 -> (結果: 真否, 結果: TimeOnly)
文字: 文字
提供者: IFormatProvider
樣式: DateTimeStylesbool TryParseTimeOnly(
string s,
IFormatProvider provider,
DateTimeStyles styles,
out TimeOnly result)嘗試按給定區域的寫法從文字中讀取時刻,失敗時報告失敗而不是出錯中止。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 文字 | 文字 | — | The text to read; null, unreadable text or text that includes a date makes the node report failure. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
| 樣式 | DateTimeStyles | — | White-space options only, such as DateTimeStyles.AllowWhiteSpaces; any other style still throws an System.ArgumentException. |
返回
| 結果 | 真否 |
| 結果 | TimeOnly |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
嘗試解析時間間隔
函數過載 1/2
嘗試解析時間間隔(文字: 文字) -> (結果: 真否, 結果: TimeSpan)
bool TryParseTimeSpan(string s, out TimeSpan result)
嘗試從形如 [-][d.]hh:mm[:ss[.fffffff]] 的文字中讀取時間間隔(不隨機器的區域改變),失敗時報告失敗而不是出錯中止。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 文字 | 文字 | — | The text to read; null, text in the wrong form or a value out of range makes the node report failure. |
返回
| 結果 | 真否 |
| 結果 | TimeSpan |
過載 2/2
嘗試解析時間間隔 -> (結果: 真否, 結果: TimeSpan)
文字: 文字
提供者: IFormatProviderbool TryParseTimeSpan(
string s,
IFormatProvider provider,
out TimeSpan result)嘗試按給定區域從形如 [-][d.]hh:mm[:ss[.fffffff]] 的文字中讀取時間間隔,失敗時報告失敗而不是出錯中止。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 文字 | 文字 | — | The text to read; null, text in the wrong form or a value out of range makes the node report failure. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
返回
| 結果 | 真否 |
| 結果 | TimeSpan |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫
年
函數過載 1/2
年(值: 時間日期) -> 整數
int Year(DateTime value)
取得時間日期的年份。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | 時間日期 | — | The date and time. |
返回
| 結果 | 整數 |
過載 2/2
年(值: DateOnly) -> 整數
int Year(DateOnly value)
取得日期的年份。
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 值 | DateOnly | — |
返回
| 結果 | 整數 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 日期時間操作
- 所屬包
- 標準庫