Class DateTimeExtensions
Extension methods for the DateTime class.
Inheritance
Inherited Members
Namespace: EPiServer.Shell.Web
Assembly: EPiServer.Shell.dll
Version: 8.11.0Syntax
public static class DateTimeExtensions
Methods
ToFriendlyDateString(DateTime)
Returns Today, Yesterday or System.DateTime.ToShortDateString.
Declaration
public static string ToFriendlyDateString(this DateTime date)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | date | The date to transform. |
Returns
Type | Description |
---|---|
System.String | A text representation of the date. |
ToFriendlyDateString(DateTime, LocalizationService)
Returns Today, Yesterday or System.DateTime.ToShortDateString.
Declaration
public static string ToFriendlyDateString(this DateTime date, LocalizationService localizationService)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | date | The date to transform. |
LocalizationService | localizationService | The service used for localization. |
Returns
Type | Description |
---|---|
System.String | A text representation of the date. |
Remarks
If localizationService
is null
,
the static instance Current will be used.
ToFriendlyDateString(Nullable<DateTime>)
Returns Today, Yesterday or System.DateTime.ToShortDateString.
Declaration
public static string ToFriendlyDateString(this DateTime? date)
Parameters
Type | Name | Description |
---|---|---|
System.Nullable<System.DateTime> | date | The date to transform. |
Returns
Type | Description |
---|---|
System.String | A text representation of the date. |
ToFriendlyDateTimeString(DateTime)
Returns Today, Yesterday or System.DateTime.ToShortDateString.
Declaration
public static string ToFriendlyDateTimeString(this DateTime date)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | date | The date to transform. |
Returns
Type | Description |
---|---|
System.String | A text representation of the date. |
ToFriendlyDateTimeString(DateTime, LocalizationService)
Returns Today, Yesterday or System.DateTime.ToShortDateString.
Declaration
public static string ToFriendlyDateTimeString(this DateTime date, LocalizationService localizationService)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | date | The date to transform. |
LocalizationService | localizationService | The service used for localization. |
Returns
Type | Description |
---|---|
System.String | A text representation of the date. |
Remarks
If localizationService
is null
,
the static instance Current will be used.
ToFriendlyDateTimeString(Nullable<DateTime>)
Returns Today, Yesterday or System.DateTime.ToShortDateString.
Declaration
public static string ToFriendlyDateTimeString(this DateTime? date)
Parameters
Type | Name | Description |
---|---|---|
System.Nullable<System.DateTime> | date | The date to transform. |
Returns
Type | Description |
---|---|
System.String | A text representation of the date. |