Converts a PSR-16 TTL value to seconds for WordPress cache functions.
Parameters
$ttlnull|int|DateIntervalrequired- The TTL value.
Source
private function ttl_to_seconds( $ttl ): int {
if ( null === $ttl ) {
return 0;
}
if ( $ttl instanceof DateInterval ) {
$now = new DateTime();
$end = ( clone $now )->add( $ttl );
return $end->getTimestamp() - $now->getTimestamp();
}
return max( 0, (int) $ttl );
}
Changelog
| Version | Description |
|---|---|
| 7.0.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.