In This Article

DateTimeExtensions Class

Provides extension methods for the DateTime type.

public static class DateTimeExtensions
Inheritance:
object object

Methods

IsToday(DateTime)

Returns whether the specified DateTime is today.

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

The DateTime to examine.

Returns

bool:

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

IsWeekend(DateTime)

Returns whether the specified DateTime is on a weekend.

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

The DateTime to examine.

Returns

bool:

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

ToString(DateTime, DateTimeFormatPattern, IFormatProvider?)

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

public static string ToString(this DateTime dateTime, DateTimeFormatPattern pattern, IFormatProvider? provider = null)
Parameter Type Description
dateTime DateTime

The DateTime to convert.

pattern DateTimeFormatPattern

A DateTimeFormatPattern specifying the conversion format pattern to use.

provider IFormatProvider

An optional IFormatProvider that supplies culture-specific formatting information. If null, CurrentInfo is used.

Returns

string

Inherited Members