共用方式為


DateTimeOffset.Minute 屬性

定義

取得目前 DateTimeOffset 物件所表示之時間的分鐘數元件。

public:
 property int Minute { int get(); };
public int Minute { get; }
member this.Minute : int
Public ReadOnly Property Minute As Integer

屬性值

Int32

目前 DateTimeOffset 物件的分鐘數元件,以 0 到 59 之間的整數表示。

範例

下列範例會以三種不同的方式顯示 物件的分鐘元件 DateTimeOffset

DateTimeOffset theTime = new DateTimeOffset(2008, 5, 1, 10, 3, 0,
                                           DateTimeOffset.Now.Offset);
Console.WriteLine("The minute component of {0} is {1}.",
                  theTime, theTime.Minute);

Console.WriteLine("The minute component of {0} is{1}.",
                  theTime, theTime.ToString(" m"));

Console.WriteLine("The minute component of {0} is {1}.",
                  theTime, theTime.ToString("mm"));
// The example produces the following output:
//    The minute component of 5/1/2008 10:03:00 AM -08:00 is 3.
//    The minute component of 5/1/2008 10:03:00 AM -08:00 is 3.
//    The minute component of 5/1/2008 10:03:00 AM -08:00 is 03.
let theTime = DateTimeOffset(2008, 5, 1, 10, 3, 0, DateTimeOffset.Now.Offset)
printfn $"The minute component of {theTime} is {theTime.Minute}."

printfn $"""The minute component of {theTime} is{theTime.ToString " m"}."""

printfn $"The minute component of {theTime} is {theTime:mm}."

// The example produces the following output:
//    The minute component of 5/1/2008 10:03:00 AM -08:00 is 3.
//    The minute component of 5/1/2008 10:03:00 AM -08:00 is 3.
//    The minute component of 5/1/2008 10:03:00 AM -08:00 is 03.
Dim theTime As New DateTimeOffset(#5/1/2008 10:03AM#, _
                                       DateTimeOffset.Now.Offset)
Console.WriteLine("The minute component of {0} is {1}.", _
                  theTime, theTime.Minute)

Console.WriteLine("The minute component of {0} is{1}.", _
                  theTime, theTime.ToString(" m"))

Console.WriteLine("The minute component of {0} is {1}.", _
                  theTime, theTime.ToString("mm"))
' The example produces the following output:
'    The minute component of 5/1/2008 10:03:00 AM -08:00 is 3.
'    The minute component of 5/1/2008 10:03:00 AM -08:00 is 3.
'    The minute component of 5/1/2008 10:03:00 AM -08:00 is 03.

備註

屬性 Minute 不會受到 屬性的值 Offset 影響。

您也可以使用 「m」 或 「mm」 自訂格式規範呼叫 方法來建立 ToString 物件的分鐘元件字串表示 DateTimeOffset

適用於