| Server IP : 208.122.213.31 / Your IP : 216.73.216.45 Web Server : Apache System : Linux msd6191.mjhst.com 4.18.0-553.137.1.el8_10.x86_64 #1 SMP Wed Jun 24 11:40:24 UTC 2026 x86_64 User : WHMCS_MIA_382 ( 1001) PHP Version : 7.4.33 Disable Function : NONE MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /proc/self/cwd/wp-content/plugins/cornerstone/includes/functions/ |
Upload File : |
<?php
/**
* From Timber
* Returns the difference between two times in a human readable format.
*
* Differentiates between past and future dates.
*
* @api
* @see \human_time_diff()
* @example
* ```twig
* {{ post.date('U')|time_ago }}
* {{ post.date('Y-m-d H:i:s')|time_ago }}
* {{ post.date(constant('DATE_ATOM'))|time_ago }}
* ```
*
* @param int|string $from Base date as a timestamp or a date string.
* @param int|string $to Optional. Date to calculate difference to as a timestamp or
* a date string. Default current time.
* @param string $format_past Optional. String to use for past dates. To be used with
* `sprintf()`. Default `%s ago`.
* @param string $format_future Optional. String to use for future dates. To be used with
* `sprintf()`. Default `%s from now`.
*
* @return string
*/
function cs_date_time_ago($from, $to = null, $format_past = null, $format_future = null)
{
if (null === $format_past) {
/* translators: %s: Human-readable time difference. */
$format_past = \__('%s ago');
}
if (null === $format_future) {
/* translators: %s: Human-readable time difference. */
$format_future = \__('%s from now');
}
$to = $to ?? \time();
$to = \is_numeric($to)
? new DateTimeImmutable('@' . $to, \wp_timezone())
: new DateTimeImmutable($to, \wp_timezone());
$from = \is_numeric($from)
? new DateTimeImmutable('@' . $from, \wp_timezone())
: new DateTimeImmutable($from, \wp_timezone());
if ($from < $to) {
return \sprintf($format_past, \human_time_diff($from->getTimestamp(), $to->getTimestamp()));
} else {
return \sprintf($format_future, \human_time_diff($to->getTimestamp(), $from->getTimestamp()));
}
}