PHP Class WPDKDateTime

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

Public Properties

Property Type Description
$__version string Override version

Public Methods

Method 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 method

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

beginningOfWeek() public static method

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`
return integer

compareDate() public static method

TO DO
public static compareDate ( )

compareDatetime() public static method

TO DO
public static compareDatetime ( )

daysToDate() public static method

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
return float

daysToWeekStart() public static method

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
return integer $date

elapsed() public static method

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

elapsedString() public static method

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 ', '.
return string

elapsed_string() public static method

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

expirationDate() public static method

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
return integer

format() public static method

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`
return string

human() public static method

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')`.
return string

isExpired() public static method

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

isInRangeDatetime() public static method

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.
return boolean

mySQLDate() public static method

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.
return string

mySQLDateTime() public static method

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.
return string

stripSecondsFromTime() public static method

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

timeInRange() public static method

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.
return boolean

timeNewLine() public static method

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

Property Details

$__version public property

Override version
public string $__version
return string