DateTime can be specified relative to local time, UTC, or unspecified.
DateTime and DateTimeOffset differ in how they handle time zones.
A DateTime incorporates a three-state flag indicating whether the DateTime is relative to:
A DateTimeOffset stores the offset from UTC as a TimeSpan:
Initializes a new instance of the DateTime structure to the specified year, month, day, hour, minute, second, and millisecond.
Syntax
public DateTime(
int year,
int month,
int day,
int hour,
int minute,
int second,
int millisecond
)
Parameters | Type | Meaning |
---|---|---|
year | System.Int32 | The year (1 through 9999). |
month | System.Int32 | The month (1 through 12). |
day | System.Int32 | The day (1 through the number of days in month). |
hour | System.Int32 | The hours (0 through 23). |
minute | System.Int32 | The minutes (0 through 59). |
second | System.Int32 | The seconds (0 through 59). |
millisecond | System.Int32 | The milliseconds (0 through 999). |
using System;
using System.Collections;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
class Program
{
static void Main()
{
DateTime date1 = new DateTime(2010, 8, 18, 16, 32, 18, 500);
Console.WriteLine(date1.ToString("M/dd/yyyy h:mm:ss.fff tt"));
}
}
The output:
8/18/2010 4:32:18.500 PM
java2s.com | Contact Us | Privacy Policy |
Copyright 2009 - 12 Demo Source and Support. All rights reserved. |
All other trademarks are property of their respective owners. |