|
Dieser Artikel wurde maschinell übersetzt. Bewegen Sie den Mauszeiger über die Sätze im Artikel, um den Originaltext anzuzeigen. Weitere Informationen
|
Übersetzung
Original
|
DateTime-Struktur
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Der DateTime-Typ macht die folgenden Member verfügbar.
| Name | Beschreibung | |
|---|---|---|
![]() ![]() ![]() ![]() | DateTime(Int64) | |
![]() ![]() ![]() ![]() | DateTime(Int64, DateTimeKind) | |
![]() ![]() ![]() ![]() | DateTime(Int32, Int32, Int32) | |
![]() ![]() | DateTime(Int32, Int32, Int32, Calendar) | |
![]() ![]() ![]() ![]() | DateTime(Int32, Int32, Int32, Int32, Int32, Int32) | |
![]() ![]() ![]() ![]() | DateTime(Int32, Int32, Int32, Int32, Int32, Int32, DateTimeKind) | |
![]() ![]() | DateTime(Int32, Int32, Int32, Int32, Int32, Int32, Calendar) | |
![]() ![]() ![]() ![]() | DateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32) | |
![]() ![]() ![]() ![]() | DateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32, DateTimeKind) | |
![]() ![]() | DateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32, Calendar) | |
![]() ![]() | DateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32, Calendar, DateTimeKind) |
| Name | Beschreibung | |
|---|---|---|
![]() ![]() ![]() ![]() | Date | |
![]() ![]() ![]() ![]() | Day | |
![]() ![]() ![]() ![]() | DayOfWeek | |
![]() ![]() ![]() ![]() | DayOfYear | |
![]() ![]() ![]() ![]() | Hour | |
![]() ![]() ![]() ![]() | Kind | |
![]() ![]() ![]() ![]() | Millisecond | |
![]() ![]() ![]() ![]() | Minute | |
![]() ![]() ![]() ![]() | Month | |
![]() ![]() ![]() ![]() ![]() | Now | |
![]() ![]() ![]() ![]() | Second | |
![]() ![]() ![]() ![]() | Ticks | |
![]() ![]() ![]() ![]() | TimeOfDay | |
![]() ![]() ![]() ![]() ![]() | Today | |
![]() ![]() ![]() ![]() ![]() | UtcNow | |
![]() ![]() ![]() ![]() | Year |
| Name | Beschreibung | |
|---|---|---|
![]() ![]() ![]() ![]() | Add | |
![]() ![]() ![]() ![]() | AddDays | |
![]() ![]() ![]() ![]() | AddHours | |
![]() ![]() ![]() ![]() | AddMilliseconds | |
![]() ![]() ![]() ![]() | AddMinutes | |
![]() ![]() ![]() ![]() | AddMonths | |
![]() ![]() ![]() ![]() | AddSeconds | |
![]() ![]() ![]() ![]() | AddTicks | |
![]() ![]() ![]() ![]() | AddYears | |
![]() ![]() ![]() ![]() ![]() | Compare | |
![]() ![]() ![]() ![]() | CompareTo(DateTime) | |
![]() ![]() | CompareTo(Object) | |
![]() ![]() ![]() ![]() ![]() | DaysInMonth | |
![]() ![]() ![]() ![]() | Equals(DateTime) | |
![]() ![]() ![]() ![]() | Equals(Object) | |
![]() ![]() ![]() ![]() ![]() | Equals(DateTime, DateTime) | |
![]() ![]() ![]() ![]() | FromBinary | |
![]() ![]() ![]() ![]() ![]() | FromFileTime | |
![]() ![]() ![]() ![]() ![]() | FromFileTimeUtc | |
![]() ![]() ![]() | FromOADate | |
![]() ![]() ![]() ![]() | GetDateTimeFormats() | |
![]() ![]() ![]() ![]() | GetDateTimeFormats(Char) | |
![]() ![]() ![]() ![]() | GetDateTimeFormats(IFormatProvider) | |
![]() ![]() ![]() ![]() | GetDateTimeFormats(Char, IFormatProvider) | |
![]() ![]() ![]() ![]() | GetHashCode | |
![]() ![]() ![]() ![]() | GetType | |
![]() ![]() | GetTypeCode | |
![]() ![]() ![]() ![]() | IsDaylightSavingTime | |
![]() ![]() ![]() ![]() ![]() | IsLeapYear | |
![]() ![]() ![]() ![]() ![]() | Parse(String) | |
![]() ![]() ![]() ![]() ![]() | Parse(String, IFormatProvider) | |
![]() ![]() ![]() ![]() ![]() | Parse(String, IFormatProvider, DateTimeStyles) | |
![]() ![]() ![]() ![]() ![]() | ParseExact(String, String, IFormatProvider) | |
![]() ![]() ![]() ![]() ![]() | ParseExact(String, String, IFormatProvider, DateTimeStyles) | |
![]() ![]() ![]() ![]() ![]() | ParseExact(String, String[], IFormatProvider, DateTimeStyles) | |
![]() ![]() ![]() ![]() ![]() | SpecifyKind | |
![]() ![]() ![]() ![]() | Subtract(DateTime) | |
![]() ![]() ![]() ![]() | Subtract(TimeSpan) | |
![]() ![]() ![]() | ToBinary | |
![]() ![]() ![]() ![]() | ToFileTime | |
![]() ![]() ![]() ![]() | ToFileTimeUtc | |
![]() ![]() ![]() ![]() | ToLocalTime | |
![]() ![]() | ToLongDateString | |
![]() ![]() | ToLongTimeString | |
![]() ![]() | ToOADate | |
![]() ![]() | ToShortDateString | |
![]() ![]() | ToShortTimeString | |
![]() ![]() ![]() ![]() | ToString() | |
![]() ![]() ![]() ![]() | ToString(IFormatProvider) | |
![]() ![]() ![]() ![]() | ToString(String) | |
![]() ![]() ![]() ![]() | ToString(String, IFormatProvider) | |
![]() ![]() ![]() ![]() | ToUniversalTime | |
![]() ![]() ![]() ![]() | TryParse(String, DateTime) | |
![]() ![]() ![]() ![]() | TryParse(String, IFormatProvider, DateTimeStyles, DateTime) | |
![]() ![]() ![]() ![]() | TryParseExact(String, String, IFormatProvider, DateTimeStyles, DateTime) | |
![]() ![]() ![]() ![]() | TryParseExact(String, String[], IFormatProvider, DateTimeStyles, DateTime) |
| Name | Beschreibung | |
|---|---|---|
![]() ![]() ![]() ![]() ![]() | Addition | |
![]() ![]() ![]() ![]() ![]() | Equality | |
![]() ![]() ![]() ![]() ![]() | GreaterThan | |
![]() ![]() ![]() ![]() ![]() | GreaterThanOrEqual | |
![]() ![]() ![]() ![]() ![]() | Inequality | |
![]() ![]() ![]() ![]() ![]() | LessThan | |
![]() ![]() ![]() ![]() ![]() | LessThanOrEqual | |
![]() ![]() ![]() ![]() ![]() | Subtraction(DateTime, DateTime) | |
![]() ![]() ![]() ![]() ![]() | Subtraction(DateTime, TimeSpan) |
| Name | Beschreibung | |
|---|---|---|
![]() ![]() ![]() ![]() ![]() | MaxValue | |
![]() ![]() ![]() ![]() ![]() | MinValue |
| Name | Beschreibung | |
|---|---|---|
![]() ![]() ![]() ![]() | IComparable.CompareTo | |
![]() ![]() ![]() | IConvertible.ToBoolean | Infrastruktur. |
![]() ![]() ![]() | IConvertible.ToByte | Infrastruktur. |
![]() ![]() ![]() | IConvertible.ToChar | Infrastruktur. |
![]() ![]() ![]() | IConvertible.ToDateTime | Infrastruktur. |
![]() ![]() ![]() | IConvertible.ToDecimal | Infrastruktur. |
![]() ![]() ![]() | IConvertible.ToDouble | Infrastruktur. |
![]() ![]() ![]() | IConvertible.ToInt16 | Infrastruktur. |
![]() ![]() ![]() | IConvertible.ToInt32 | Infrastruktur. |
![]() ![]() ![]() | IConvertible.ToInt64 | Infrastruktur. |
![]() ![]() ![]() | IConvertible.ToSByte | Infrastruktur. |
![]() ![]() ![]() | IConvertible.ToSingle | Infrastruktur. |
![]() ![]() ![]() | IConvertible.ToType | Infrastruktur. |
![]() ![]() ![]() | IConvertible.ToUInt16 | Infrastruktur. |
![]() ![]() ![]() | IConvertible.ToUInt32 | Infrastruktur. |
![]() ![]() ![]() | IConvertible.ToUInt64 | Infrastruktur. |
![]() ![]() | ISerializable.GetObjectData |
Hinweis |
|---|
Instanziieren eines DateTime-Objekts
Durch das Aufrufen einer der Überladungen des DateTime-Konstruktors, die das Angeben spezifischer Elemente des Datums- und Uhrzeitwerts (wie Jahr, Monat und Tag oder Anzahl der Ticks) ermöglichen. Die folgende Anweisung veranschaulicht einen Aufruf eines der DateTime-Konstruktoren, um ein Datum mit den spezifischen Angaben für Jahr, Monat, Tag, Stunde, Minute und Sekunde zu erstellen. Durch das Verwenden einer compilerspezifischen Syntax zum Deklarieren von Datums- und Uhrzeitwerten. Durch die folgende Visual Basic-Anweisung wird z. B. ein neuer DateTime-Wert initialisiert. Dim date1 As Date = #5/1/2008 8:30:52AM#
Durch das Zuweisen eines Datums- und Uhrzeitwerts zum DateTime-Objekt, der von einer Eigenschaft oder einer Methode zurückgegeben wurde. Im folgenden Beispiel werden drei neuen DateTime-Variablen das aktuelle Datum und die aktuelle Uhrzeit, die aktuellen UTC-Werte (Coordinated Universal Time) für Datum und Uhrzeit sowie das aktuelle Datum zugewiesen. Durch das Analysieren der Zeichenfolgendarstellung eines Datums- und Uhrzeitwerts. Die Methoden Parse, ParseExact, TryParse und TryParseExact konvertieren eine Zeichenfolge in ihren entsprechenden Datums- und Uhrzeitwert. Im folgenden Beispiel wird mit der Parse-Methode eine Zeichenfolge analysiert und in einen DateTime-Wert konvertiert. Beachten Sie, dass die Methoden TryParse und TryParseExact zusätzlich zum Durchführen der Konvertierung angeben, ob eine bestimmte Zeichenfolge eine gültige Darstellung eines DateTime-Werts enthält. Durch das Aufrufen des impliziten Standardkonstruktors der DateTime-Struktur. (Einzelheiten zum impliziten Standardkonstruktor eines Werttyps finden Sie unter Werttypen (C#-Referenz).) Eine jeweilige Entsprechung, für Compiler, die sie unterstützen, deklariert einen DateTime-Wert, ohne ein Datum und eine Uhrzeit an sie explizit zuweisen. Im folgenden Beispiel werden ein Aufruf des impliziten DateTime-Standardkonstruktors in C# und Visual Basic sowie eine DateTime-Variablendeklaration ohne Zuweisung in Visual Basic veranschaulicht.
DateTime-Werte und ihre Zeichenfolgendarstellungen
Versionsaspekte
Hinweis |
|---|
DateTime-Werte
DateTime-Operationen
DateTime VS. Zeitspanne
COM-Interop-Überlegungen
using System; class DateTimeTester { static bool RoughlyEquals(DateTime time, DateTime timeWithWindow, int windowInSeconds, int frequencyInSeconds) { long delta = (long)((TimeSpan)(timeWithWindow - time)).TotalSeconds % frequencyInSeconds; delta = delta > windowInSeconds ? frequencyInSeconds - delta : delta; return Math.Abs(delta) < windowInSeconds; } public static void Main() { int window = 10; int freq = 60 * 60 * 2; // 2 hours; DateTime d1 = DateTime.Now; DateTime d2 = d1.AddSeconds(2 * window); DateTime d3 = d1.AddSeconds(-2 * window); DateTime d4 = d1.AddSeconds(window / 2); DateTime d5 = d1.AddSeconds(-window / 2); DateTime d6 = (d1.AddHours(2)).AddSeconds(2 * window); DateTime d7 = (d1.AddHours(2)).AddSeconds(-2 * window); DateTime d8 = (d1.AddHours(2)).AddSeconds(window / 2); DateTime d9 = (d1.AddHours(2)).AddSeconds(-window / 2); Console.WriteLine("d1 ({0}) ~= d1 ({1}): {2}", d1, d1, RoughlyEquals(d1, d1, window, freq)); Console.WriteLine("d1 ({0}) ~= d2 ({1}): {2}", d1, d2, RoughlyEquals(d1, d2, window, freq)); Console.WriteLine("d1 ({0}) ~= d3 ({1}): {2}", d1, d3, RoughlyEquals(d1, d3, window, freq)); Console.WriteLine("d1 ({0}) ~= d4 ({1}): {2}", d1, d4, RoughlyEquals(d1, d4, window, freq)); Console.WriteLine("d1 ({0}) ~= d5 ({1}): {2}", d1, d5, RoughlyEquals(d1, d5, window, freq)); Console.WriteLine("d1 ({0}) ~= d6 ({1}): {2}", d1, d6, RoughlyEquals(d1, d6, window, freq)); Console.WriteLine("d1 ({0}) ~= d7 ({1}): {2}", d1, d7, RoughlyEquals(d1, d7, window, freq)); Console.WriteLine("d1 ({0}) ~= d8 ({1}): {2}", d1, d8, RoughlyEquals(d1, d8, window, freq)); Console.WriteLine("d1 ({0}) ~= d9 ({1}): {2}", d1, d9, RoughlyEquals(d1, d9, window, freq)); } } // The example displays output similar to the following: // d1 (1/28/2010 9:01:26 PM) ~= d1 (1/28/2010 9:01:26 PM): True // d1 (1/28/2010 9:01:26 PM) ~= d2 (1/28/2010 9:01:46 PM): False // d1 (1/28/2010 9:01:26 PM) ~= d3 (1/28/2010 9:01:06 PM): False // d1 (1/28/2010 9:01:26 PM) ~= d4 (1/28/2010 9:01:31 PM): True // d1 (1/28/2010 9:01:26 PM) ~= d5 (1/28/2010 9:01:21 PM): True // d1 (1/28/2010 9:01:26 PM) ~= d6 (1/28/2010 11:01:46 PM): False // d1 (1/28/2010 9:01:26 PM) ~= d7 (1/28/2010 11:01:06 PM): False // d1 (1/28/2010 9:01:26 PM) ~= d8 (1/28/2010 11:01:31 PM): True // d1 (1/28/2010 9:01:26 PM) ~= d9 (1/28/2010 11:01:21 PM): True
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core-Rolle wird nicht unterstützt), Windows Server 2008 R2 (Server Core-Rolle wird mit SP1 oder höher unterstützt; Itanium wird nicht unterstützt)
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen für .NET Framework.
Vorsicht |
|---|


