In This Article

DateTimeExtensions Class

Provides extension methods for the type DateTime.

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)

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

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

The DateTime to convert.

pattern DateTimeFormatPattern

A DateTimeFormatPattern specifying the conversion pattern to use.

Returns

string:

The string representation of the DateTime.

ToString(DateTime, DateTimeFormatPattern, IFormatProvider)

Converts the value of a 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 DateTime

The DateTime to convert.

pattern DateTimeFormatPattern

A DateTimeFormatPattern specifying the conversion pattern to use.

provider IFormatProvider

An IFormatProvider that supplies culture-specific formatting information.

Returns

string:

The string representation of the DateTime.

Inherited Members