C# DateTime DateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32)
Description
DateTime DateTime(Int32, Int32, Int32, Int32, Int32, Int32,
Int32)
initializes a new instance of the DateTime structure to the
specified year, month, day, hour, minute, second, and millisecond.
Syntax
DateTime.DateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32)
has the following syntax.
public DateTime(/*from www . j a va 2s .c o m*/
int year,
int month,
int day,
int hour,
int minute,
int second,
int millisecond
)
Parameters
DateTime.DateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32)
has the following parameters.
year
- The year (1 through 9999).month
- The month (1 through 12).day
- The day (1 through the number of days in month).hour
- The hours (0 through 23).minute
- The minutes (0 through 59).second
- The seconds (0 through 59).millisecond
- The milliseconds (0 through 999).
Example
The following example uses the DateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32) constructor to instantiate a DateTime value.
using System;/* w w w. j av a 2 s .c o m*/
public class MainClass{
public static void Main(String[] argv){
DateTime date1 = new DateTime(2010, 8, 18, 16, 32, 18, 500);
System.Console.WriteLine(date1.ToString("M/dd/yyyy h:mm:ss.fff tt"));
}
}
The code above generates the following result.