In This Article

DateTimeExtensions Class

Provides extension methods for the type System.DateTime.

public static class DateTimeExtensions
Inheritance:
System.Object Object

Methods

IsToday(DateTime)

Returns whether the specified System.DateTime is today.

public static bool IsToday(this DateTime dateTime)
Parameter Type Description
dateTime System.DateTime

The System.DateTime to examine.

Returns

System.Boolean:

true if the specified System.DateTime is today; otherwise, false.

IsWeekend(DateTime)

Returns whether the specified System.DateTime is on a weekend.

public static bool IsWeekend(this DateTime dateTime)
Parameter Type Description
dateTime System.DateTime

The System.DateTime to examine.

Returns

System.Boolean:

true if the specified System.DateTime is on a weekend; otherwise, false.

ToString(DateTime, DateTimeFormatPattern)

Converts the value of a System.DateTime object to its equivalent string representation using the specified pattern.

public static string ToString(this DateTime dateTime, DateTimeFormatPattern pattern)
Parameter Type Description
dateTime System.DateTime

The System.DateTime to convert.

pattern DateTimeFormatPattern

A DateTimeFormatPattern specifying the conversion pattern to use.

Returns

System.String:

The string representation of the System.DateTime.

ToString(DateTime, DateTimeFormatPattern, IFormatProvider)

Converts the value of a System.DateTime object to its equivalent string representation using the specified pattern and culture-specific format information.

public static string ToString(this DateTime dateTime, DateTimeFormatPattern pattern, IFormatProvider provider)
Parameter Type Description
dateTime System.DateTime

The System.DateTime to convert.

pattern DateTimeFormatPattern

A DateTimeFormatPattern specifying the conversion pattern to use.

provider System.IFormatProvider

An System.IFormatProvider that supplies culture-specific formatting information.

Returns

System.String:

The string representation of the System.DateTime.

Inherited Members

  • System.Object.ToString()
  • System.Object.Equals(System.Object)
  • System.Object.Equals(System.Object, System.Object)
  • System.Object.ReferenceEquals(System.Object, System.Object)
  • System.Object.GetHashCode()
  • System.Object.GetType()
  • System.Object.MemberwiseClone()