C# DateTime

19 functions

DateTime.NowDateTime.Now

Gets the current date and time.

DateTime.UtcNowDateTime.UtcNow

Gets the current UTC date and time.

DateTime.TodayDateTime.Today

Gets the current date with the time component set to midnight.

new DateTimenew DateTime(year, month, day)

Initializes a new DateTime with specified year, month, and day.

AddYearsdt.AddYears(value)

Returns a new DateTime with the specified number of years added.

AddMonthsdt.AddMonths(months)

Returns a new DateTime with the specified number of months added.

AddDaysdt.AddDays(value)

Returns a new DateTime with the specified number of days added.

AddHoursdt.AddHours(value)

Returns a new DateTime with the specified number of hours added.

AddMinutesdt.AddMinutes(value)

Returns a new DateTime with the specified number of minutes added.

Subtractdt.Subtract(value)

Returns the difference between two DateTime values as a TimeSpan.

ToStringdt.ToString(format?)

Converts the value of the current DateTime to its equivalent string representation.

DayOfWeekdt.DayOfWeek

Gets the day of the week represented by this instance.

DayOfYeardt.DayOfYear

Gets the day of the year represented by this instance.

DateTime.ParseDateTime.Parse(s)

Converts the string to a DateTime equivalent.

DateTime.TryParseDateTime.TryParse(s, out result)

Converts the string to a DateTime, returning true if successful.

DateTime.DaysInMonthDateTime.DaysInMonth(year, month)

Returns the number of days in the specified month and year.

DateTime.IsLeapYearDateTime.IsLeapYear(year)

Returns an indication whether the specified year is a leap year.

TimeSpan.FromDaysTimeSpan.FromDays(value)

Returns a TimeSpan that represents a specified number of days.

TimeSpan.TotalDaystimespan.TotalDays

Gets the total number of days represented by this TimeSpan.