ap_human_time( string $time, boolean $unix = true, integer $show_full_date = 604800, boolean|string $format = false )
Description #
Return human readable time format.
Parameters #
- $timestring (Required) Time.
- $unixboolean (Optional) Is $time is unix. Default value: true
- $show_full_dateinteger (Optional) Show full date after some period. Default is 7 days in epoch. Default value: 604800
- $formatboolean | string (Optional) Date format. Default value: false
Source #
File: includes/functions.php
function ap_human_time( $time, $unix = true, $show_full_date = 604800, $format = false ) {
if ( false === $format ) {
$format = get_option( 'date_format' );
}
if ( ! is_numeric( $time ) && ! $unix ) {
$time = strtotime( $time );
}
// If default date format is enabled then just return date.
if ( ap_opt( 'default_date_format' ) ) {
return date_i18n( $format, $time );
}
if ( $time ) {
if ( $show_full_date + $time > time() ) {
return sprintf(
/* translators: %s: human-readable time difference */
__( '%s ago', 'anspress-question-answer' ),
human_time_diff( $time, time() )
);
}
return date_i18n( $format, $time );
}
}
Expand full source code Collapse full source code View on GitHub: includes/functions.php:239
Add your comment