Diff: STRATO-apps/wordpress_03/app/wp-content/plugins/wp-rocket/inc/Engine/Common/Clock/WPRClock.php
Keine Baseline-Datei – Diff nur gegen leer.
1
-
1
+
<?php
2
+
3
+
namespace WP_Rocket\Engine\Common\Clock;
4
+
5
+
class WPRClock implements ClockInterface {
6
+
7
+
/**
8
+
* Retrieves the current time based on specified type.
9
+
*
10
+
* - The 'mysql' type will return the time in the format for MySQL DATETIME field.
11
+
* - The 'timestamp' or 'U' types will return the current timestamp or a sum of timestamp
12
+
* and timezone offset, depending on `$gmt`.
13
+
* - Other strings will be interpreted as PHP date formats (e.g. 'Y-m-d').
14
+
*
15
+
* If `$gmt` is a truthy value then both types will use GMT time, otherwise the
16
+
* output is adjusted with the GMT offset for the site.
17
+
*
18
+
* @since 1.0.0
19
+
* @since 5.3.0 Now returns an integer if `$type` is 'U'. Previously a string was returned.
20
+
*
21
+
* @param string $type Type of time to retrieve. Accepts 'mysql', 'timestamp', 'U',
22
+
* or PHP date format string (e.g. 'Y-m-d').
23
+
* @param int|bool $gmt Optional. Whether to use GMT timezone. Default false.
24
+
*
25
+
* @return int|string Integer if `$type` is 'timestamp' or 'U', string otherwise.
26
+
*/
27
+
public function current_time( string $type, $gmt = 0 ) {
28
+
$current_time = current_time( $type, $gmt );
29
+
$output = apply_filters( 'rocket_current_time', $current_time );
30
+
if ( ( is_string( $current_time ) && strtotime( $current_time ) ) || ( is_int( $current_time ) && $current_time >= 0 ) ) {
31
+
return $output;
32
+
}
33
+
return $current_time;
34
+
}
35
+
}
36
+