PHP Class WPDKDateTime

Author: =undo= ([email protected])
Inheritance: extends WPDKObject
Afficher le fichier Open project: wpxtreme/wpdk Class Usage Examples

Méthodes publiques

Свойство Type Description
$__version string Override version

Méthodes publiques

Méthode Description
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.

Method Details

accuracy() public static méthode

Return the accuracy date format
Since: 1.5.3
public static accuracy ( string $v = false ) : string
$v string Optional. Any acuracy 'seconds', 'hours', etc...
Résultat string

beginningOfWeek() public static méthode

Returns number of days to start of this week.
Author: =stid= ([email protected])
public static beginningOfWeek ( string $date, string $first_day = 'monday' ) : integer
$date string
$first_day string Optional. Start from `monday`
Résultat integer

compareDate() public static méthode

TO DO
public static compareDate ( )

compareDatetime() public static méthode

TO DO
public static compareDatetime ( )

daysToDate() public static méthode

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
Résultat float

daysToWeekStart() public static méthode

Returns number of days to start of this week.
Author: =stid= ([email protected])
public static daysToWeekStart ( object $date, string $first_day = 'monday' ) : integer
$date object Date object
$first_day string
Résultat integer $date

elapsed() public static méthode

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

elapsedString() public static méthode

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 ', '.
Résultat string

elapsed_string() public static méthode

Deprecation: since 1.5.13 - Use elapsedString() instead
public static elapsed_string ( $timestamp, $hide_empty = true, $to, $separator = ' ' )

expirationDate() public static méthode

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
Résultat integer

format() public static méthode

Format a date time in your custom own format. The source format is auto-detect.
Since: 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`
Résultat string

human() public static méthode

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')`.
Résultat string

isExpired() public static méthode

Return TRUE if $expiration date is past.
public static isExpired ( integer $exipration ) : boolean
$exipration integer Timestamp date to check
Résultat boolean

isInRangeDatetime() public static méthode

Return TRUE if now (today) is between from two date.
Deprecation: 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.
Résultat boolean

mySQLDate() public static méthode

Return a date in MySQL format YYYY-MM-DD.
Since: 1.3.0
public static mySQLDate ( string | integer $date ) : string
$date string | integer A string date or timestamp.
Résultat string

mySQLDateTime() public static méthode

Return a date and time in MySQL format YYYY-MM-DD HH:MM:SS.
Since: 1.3.0
public static mySQLDateTime ( string | integer $datetime ) : string
$datetime string | integer A string date or timestamp.
Résultat string

stripSecondsFromTime() public static méthode

Strip seconds from a date string (with time)
public static stripSecondsFromTime ( string $time ) : string
$time string Time in hh:mm:ss
Résultat string

timeInRange() public static méthode

Return TRUE if now time() is between $start and $expry.
Since: 1.5.16
public static timeInRange ( integer $start, integer $expiry ) : boolean
$start integer Start date.
$expiry integer Expiry date.
Résultat boolean

timeNewLine() public static méthode

Put a new line before time.
public static timeNewLine ( string $datetime ) : string
$datetime string Date with time.
Résultat string

Property Details

$__version public_oe property

Override version
public string $__version
Résultat string