C# DateTime DateTime(Int32, Int32, Int32, Int32, Int32, Int32)
Description
DateTime DateTime(Int32, Int32, Int32, Int32, Int32, Int32)
initializes a new instance of the DateTime structure to the specified
year, month, day, hour, minute, and second.
Syntax
DateTime.DateTime(Int32, Int32, Int32, Int32, Int32, Int32)
has the following syntax.
public DateTime(//w w w. j av a 2 s . c o m
int year,
int month,
int day,
int hour,
int minute,
int second
)
Parameters
DateTime.DateTime(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).
Example
The following example uses the DateTime constructor to instantiate a DateTime value.
using System;// www. j a v a2 s. c o m
public class MainClass{
public static void Main(String[] argv){
DateTime date1 = new DateTime(2010, 8, 18, 16, 32, 0);
System.Console.WriteLine(date1.ToString());
}
}
The code above generates the following result.