Class humhub\libs\DateHelper

Inheritancehumhub\libs\DateHelper

Utility class for date issues

See also \yii\validators\DateValidator.

Public Methods

Hide inherited methods

MethodDescriptionDefined By
getSystemTimeZone() humhub\libs\DateHelper
getUserTimeZone() Returns the user timeZone or app timezone as fallback. humhub\libs\DateHelper
isInDbFormat() Checks whether the given value is a db date format or not. humhub\libs\DateHelper
parseDateTime() Parses a date and optionally a time if timeAttribute is specified to an given pattern or the default pattern 'Y-m-d' if no pattern is provided. humhub\libs\DateHelper
parseDateTimeToTimestamp() Parses a date and optionally a time if timeAttribute is specified. humhub\libs\DateHelper

Constants

Hide inherited constants

ConstantValueDescriptionDefined By
DB_DATE_FORMAT 'Y-m-d H:i:s' humhub\libs\DateHelper
DB_DATE_FORMAT_PHP 'php:Y-m-d H:i:s' humhub\libs\DateHelper
REGEX_DBFORMAT_DATE '/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/' humhub\libs\DateHelper
REGEX_DBFORMAT_DATETIME '/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1]) (\d{2}):(\d{2}):(\d{2})$/' humhub\libs\DateHelper

Method Details

getSystemTimeZone() public static method

public static DateTimeZone|string getSystemTimeZone ( $asString false )
$asString boolean
getUserTimeZone() public static method

Returns the user timeZone or app timezone as fallback.

public static DateTimeZone|string getUserTimeZone ( $asString false )
$asString
isInDbFormat() public static method

Checks whether the given value is a db date format or not.

public static boolean isInDbFormat ( $value )
$value string

The date value

parseDateTime() public static method

Parses a date and optionally a time if timeAttribute is specified to an given pattern or the default pattern 'Y-m-d' if no pattern is provided.

public static integer parseDateTime ( $value, $pattern 'Y-m-d', $timeValue null )
$value string

Date value

$pattern string

Pattern

$timeValue string

Optional time value

return integer

Timestamp in utc

throws Exception
parseDateTimeToTimestamp() public static method

Parses a date and optionally a time if timeAttribute is specified.

public static integer parseDateTimeToTimestamp ( $value, $timeValue null )
$value string
$timeValue string

Optional time value

return integer

Timestamp in utc

throws Exception