PHP Класс WPDKDateTime

Автор: =undo= ([email protected])
Наследование: extends WPDKObject
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$__version string Override version

Открытые методы

Метод Описание
accuracy ( string $v = false ) : string Return the accuracy date format
beginningOfWeek ( string $date, string $first_day = 'monday' ) : integer Returns number of days to start of this week.
compareDate ( ) TO DO
compareDatetime ( ) TO DO
daysToDate ( integer $date ) : float Return the days to a expiration date from now. Return the days to up ($date > now) or days expired ($date < now).
daysToWeekStart ( object $date, string $first_day = 'monday' ) : integer Returns number of days to start of this week.
elapsed ( $timestamp, $to = false, $w = 's' ) TODO proto
elapsedString ( integer $timestamp, boolean $hide_empty = true, integer $to, string $separator = ', ' ) : string This method is similar to WordPress human_time_diff(), with the different that every amount is display.
elapsed_string ( $timestamp, $hide_empty = true, $to, $separator = ' ' )
expirationDate ( string $date, integer $duration, string $duration_type ) : integer Return a timestamp as sum from $date and $duration/$duration_type
format ( string | integer $date, string $to = self::DATETIME_FORMAT_PHP ) : string Format a date time in your custom own format. The source format is auto-detect.
human ( string | integer $date, string $format = false ) : string Return an more readable human date format.
isExpired ( integer $exipration ) : boolean Return TRUE if $expiration date is past.
isInRangeDatetime ( string | integer $date_start, string | integer $date_expire, string $format = 'YmdHis', boolean $timestamp = false ) : boolean Return TRUE if now (today) is between from two date.
mySQLDate ( string | integer $date ) : string Return a date in MySQL format YYYY-MM-DD.
mySQLDateTime ( string | integer $datetime ) : string Return a date and time in MySQL format YYYY-MM-DD HH:MM:SS.
stripSecondsFromTime ( string $time ) : string Strip seconds from a date string (with time)
timeInRange ( integer $start, integer $expiry ) : boolean Return TRUE if now time() is between $start and $expry.
timeNewLine ( string $datetime ) : string Put a new line before time.

Описание методов

accuracy() публичный статический Метод

Return the accuracy date format
С версии: 1.5.3
public static accuracy ( string $v = false ) : string
$v string Optional. Any acuracy 'seconds', 'hours', etc...
Результат string

beginningOfWeek() публичный статический Метод

Returns number of days to start of this week.
Автор: =stid= ([email protected])
public static beginningOfWeek ( string $date, string $first_day = 'monday' ) : integer
$date string
$first_day string Optional. Start from `monday`
Результат integer

compareDate() публичный статический Метод

TO DO
public static compareDate ( )

compareDatetime() публичный статический Метод

TO DO
public static compareDatetime ( )

daysToDate() публичный статический Метод

Return the days to a expiration date from now. Return the days to up ($date > now) or days expired ($date < now).
public static daysToDate ( integer $date ) : float
$date integer A timestamp date
Результат float

daysToWeekStart() публичный статический Метод

Returns number of days to start of this week.
Автор: =stid= ([email protected])
public static daysToWeekStart ( object $date, string $first_day = 'monday' ) : integer
$date object Date object
$first_day string
Результат integer $date

elapsed() публичный статический Метод

TODO proto
public static elapsed ( $timestamp, $to = false, $w = 's' )

elapsedString() публичный статический Метод

For example if WordPress human_time_diff() display '10 hours', this method display '9 Hours 47 Minutes 56 Seconds'.
public static elapsedString ( integer $timestamp, boolean $hide_empty = true, integer $to, string $separator = ', ' ) : string
$timestamp integer Date from elapsed
$hide_empty boolean Optional. If TRUE '0 Year' will not return. Default TRUE.
$to integer Optional. Date to elapsed. If empty time() is used
$separator string Optional. Separator, default ', '.
Результат string

elapsed_string() публичный статический Метод

Устаревший: since 1.5.13 - Use elapsedString() instead
public static elapsed_string ( $timestamp, $hide_empty = true, $to, $separator = ' ' )

expirationDate() публичный статический Метод

Return a timestamp as sum from $date and $duration/$duration_type
public static expirationDate ( string $date, integer $duration, string $duration_type ) : integer
$date string Start date in MySQL format as YYYY-MM-DD HH:MM:SS
$duration integer Duration
$duration_type string Type as `days`, `minutes`, `months
Результат integer

format() публичный статический Метод

Format a date time in your custom own format. The source format is auto-detect.
С версии: 1.0.0
public static format ( string | integer $date, string $to = self::DATETIME_FORMAT_PHP ) : string
$date string | integer Source date string format. You can use a timestamp too.
$to string Optional. Output format. Default `Welf::DATETIME_FORMAT_PHP`
Результат string

human() публичный статический Метод

Return an more readable human date format.
public static human ( string | integer $date, string $format = false ) : string
$date string | integer String date or timestamp
$format string Optional. Default `get_option('date_format')`.
Результат string

isExpired() публичный статический Метод

Return TRUE if $expiration date is past.
public static isExpired ( integer $exipration ) : boolean
$exipration integer Timestamp date to check
Результат boolean

isInRangeDatetime() публичный статический Метод

Return TRUE if now (today) is between from two date.
Устаревший: since 1.5.16
public static isInRangeDatetime ( string | integer $date_start, string | integer $date_expire, string $format = 'YmdHis', boolean $timestamp = false ) : boolean
$date_start string | integer Start date in string or timestamp.
$date_expire string | integer Expire date in string or timestamp.
$format string Date format for start and expire.
$timestamp boolean TRUE if the date are in timestamp format.
Результат boolean

mySQLDate() публичный статический Метод

Return a date in MySQL format YYYY-MM-DD.
С версии: 1.3.0
public static mySQLDate ( string | integer $date ) : string
$date string | integer A string date or timestamp.
Результат string

mySQLDateTime() публичный статический Метод

Return a date and time in MySQL format YYYY-MM-DD HH:MM:SS.
С версии: 1.3.0
public static mySQLDateTime ( string | integer $datetime ) : string
$datetime string | integer A string date or timestamp.
Результат string

stripSecondsFromTime() публичный статический Метод

Strip seconds from a date string (with time)
public static stripSecondsFromTime ( string $time ) : string
$time string Time in hh:mm:ss
Результат string

timeInRange() публичный статический Метод

Return TRUE if now time() is between $start and $expry.
С версии: 1.5.16
public static timeInRange ( integer $start, integer $expiry ) : boolean
$start integer Start date.
$expiry integer Expiry date.
Результат boolean

timeNewLine() публичный статический Метод

Put a new line before time.
public static timeNewLine ( string $datetime ) : string
$datetime string Date with time.
Результат string

Описание свойств

$__version публичное свойство

Override version
public string $__version
Результат string