Table of Contents

Class DateTimeHelper

Namespace
CMS.Helpers
Assembly
CMS.Helpers.dll

Methods to work with the DateTime.

public static class DateTimeHelper
Inheritance
object
DateTimeHelper

Fields

MACRO_DATE_TODAY

Macro representing current date.

public const string MACRO_DATE_TODAY = "##TODAY##"

Field Value

string

MACRO_TIME_NOW

Macro representing current date and time.

public const string MACRO_TIME_NOW = "##NOW##"

Field Value

string

ZERO_TIME

Zero time constant.

public static readonly DateTime ZERO_TIME

Field Value

DateTime

Methods

GetDayStart(DateTime)

Gets start of the day of specific date.

[Obsolete("Method is deprecated and will be removed in the next version.")]
[ObsoleteSince(29, 6)]
public static DateTime GetDayStart(DateTime date)

Parameters

date DateTime

Date

Returns

DateTime

GetHourStart(DateTime)

Gets current date without minutes and seconds.

[Obsolete("Method is deprecated and will be removed in the next version.")]
[ObsoleteSince(29, 6)]
public static DateTime GetHourStart(DateTime date)

Parameters

date DateTime

Date

Returns

DateTime

GetMonthStart(DateTime)

Gets the first day of the month from specific date.

[Obsolete("Method is deprecated and will be removed in the next version.")]
[ObsoleteSince(29, 6)]
public static DateTime GetMonthStart(DateTime date)

Parameters

date DateTime

Date

Returns

DateTime

GetWeekStart(DateTime, string)

Gets the date from the beginning of week.

[Obsolete("Method is deprecated and will be removed in the next version.")]
[ObsoleteSince(29, 6)]
public static DateTime GetWeekStart(DateTime date, string culture = null)

Parameters

date DateTime

Date of week

culture string

Culture

Returns

DateTime

GetYearStart(DateTime)

Gets the first day of the year from specific date.

[Obsolete("Method is deprecated and will be removed in the next version.")]
[ObsoleteSince(29, 6)]
public static DateTime GetYearStart(DateTime date)

Parameters

date DateTime

Date

Returns

DateTime

IsNowOrToday(string)

Returns true, if the given value is ##NOW## or ##TODAY## macro

public static bool IsNowOrToday(string value)

Parameters

value string

Value to check

Returns

bool