DateTime

常用属性

  名称 说明
Now

获取当前时间.

UtcNow

获取一个 DateTime 对象,该对象设置为此计算机上的当前日期和时间,表示为协调通用时间 (UTC)。

Year

获取此实例所表示日期的年份部分。

Month

获取此实例所表示日期的月份部分。

Hour

获取此实例所表示日期的小时部分。

Minute

获取此实例所表示时间的分钟部分。

Second

获取此实例所表示日期的秒部分。

Millisecond

获取此实例所表示日期的毫秒部分。

Ticks

获取表示此实例的日期和时间的计时周期数。

TimeOfDay

获取此实例的当天的时间。

Today

获取当前日期。

Date

获取此实例的日期部分。

DayOfYear

获取此实例所表示的日期是该年中的第几天。

Day

获取此实例所表示的日期为该月中的第几天。

DayOfWeek

获取此实例所表示的日期是星期几。

常用方法

 

  名称 说明
Add(TimeSpan)

Returns a new DateTime that adds the value of the specifiedTimeSpan to the value of this instance.

AddYears(Int32)

Returns a new DateTime that adds the specified number of years to the value of this instance.

AddMonths(Int32)

返回一个新的 DateTime,它将指定的月数加到此实例的值上。

AddDays(Double)

返回一个新的 DateTime,它将指定的天数加到此实例的值上。

AddHours(Double)

返回一个新的 DateTime,它将指定的小时数加到此实例的值上。

AddMinutes(Double)

返回一个新的 DateTime,它将指定的分钟数加到此实例的值上。

AddSeconds(Double)

返回一个新的 DateTime,它将指定的秒数加到此实例的值上。

AddMilliseconds(Double)

返回一个新的 DateTime,它将指定的毫秒数加到此实例的值上。

AddTicks(Int64)

Returns a new DateTime that adds the specified number of ticks to the value of this instance.

Compare(DateTime, DateTime)

Compares two instances of DateTime and returns an integer that indicates whether the first instance is earlier than, the same as, or later than the second instance.

CompareTo(DateTime)

Compares the value of this instance to a specified DateTimevalue and returns an integer that indicates whether this instance is earlier than, the same as, or later than the specified DateTime value.

CompareTo(Object)

将此实例的值与包含指定的 DateTime 值的指定对象相比较,并返回一个整数,该整数指示此实例是早于、等于还是晚于指定的DateTime 值。

DaysInMonth(Int32, Int32)

返回指定年和月中的天数。

Equals(DateTime)

返回一个值,该值指示此实例的值是否等于指定 DateTime 实例的值。

Equals(DateTime, DateTime)

返回一个值,该值指示的两个 DateTime 实例是否具有同一个日期和时间值。

IsLeapYear(Int32)

返回指定的年份是否为闰年的指示。

Parse(String)

将日期和时间的字符串表示形式转换为其等效的 DateTime。

Subtract(DateTime)

从此实例中减去指定的日期和时间。

Subtract(TimeSpan)

Subtracts the specified duration from this instance.

ToShortDateString()

将当前 DateTime 对象的值转换为其等效的短日期字符串表示形式。

ToShortTimeString()

将当前 DateTime 对象的值转换为其等效的短时间字符串表示形式。

ToString(String)

使用指定的格式将当前 DateTime 对象的值转换为它的等效字符串表示形式。

你可能感兴趣的:(DateTime)