C# DateTime DateTime(Int32, Int32, Int32, Int32, Int32, Int32, DateTimeKind)

Description

DateTime DateTime(Int32, Int32, Int32, Int32, Int32, Int32, DateTimeKind) initializes a new instance of the DateTime structure to the specified year, month, day, hour, minute, second, and Coordinated Universal Time (UTC) or local time.

Syntax

DateTime.DateTime(Int32, Int32, Int32, Int32, Int32, Int32, DateTimeKind) has the following syntax.


public DateTime(// www.  j a  v  a  2 s.  c  om
  int year,
  int month,
  int day,
  int hour,
  int minute,
  int second,
  DateTimeKind kind
)

Parameters

DateTime.DateTime(Int32, Int32, Int32, Int32, Int32, Int32, DateTimeKind) 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).
  • kind - One of the enumeration values that indicates whether year, month, day, hour, minute and second specify a local time, Coordinated Universal Time (UTC), or neither.

Example

The following example uses the DateTime(Int32, Int32, Int32, Int32, Int32, Int32, DateTimeKind) constructor to instantiate a DateTime value.


using System;// w  w w.  ja  v a 2s  . c o  m
public class MainClass{
  public static void Main(String[] argv){  
    DateTime date1 = new DateTime(2010, 8, 18, 16, 32, 0, DateTimeKind.Local);
    System.Console.WriteLine("{0} {1}", date1, date1.Kind);
  }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version