DateTime Constructor (Int32, Int32, Int32)
.NET Framework 2.0
Initializes a new instance of the DateTime structure to the specified year, month, and day.
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly: mscorlib (in mscorlib.dll)
The time of day for the resulting DateTime is midnight (00:00:00). The Kind property is initialized to Unspecified.
The following code example demonstrates one of the DateTime constructors.
// Create a new instance of DateTime containing the date // 7/28/1979 at 10:35:05 PM using the en-US calendar. System::Globalization::CultureInfo^ info = gcnew System::Globalization::CultureInfo( "en-US",false ); System::Globalization::Calendar^ calendar = info->Calendar; System::DateTime dateTime = System::DateTime( 1979, // Year 07, // Month 28, // Day 22, // Hour 35, // Minute 5, // Second 15, // Millisecond calendar // Calendar ); // Write the DateTime as "Saturday, July 28, 1979 10:35:05 PM". System::Console::WriteLine( "{0:F}", dateTime );
// Create a new instance of DateTime containing the date
// 7/28/1979 at 10:35:05 PM using the en-US calendar.
System.Globalization.CultureInfo info = new System.Globalization.
CultureInfo("en-US", false);
System.Globalization.Calendar calendar = info.get_Calendar();
System.DateTime dateTime = new System.DateTime(
1979, // Year
07, // Month
28, // Day
22, // Hour
35, // Minute
5, // Second
15, // Millisecond
calendar // Calendar
);
// Write the DateTime as "Saturday, July 28, 1979 10:35:05 PM".
System.Console.WriteLine("{0:F}", dateTime);
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.
Community Additions
ADD
Show: