Tribe__Date_Utils::round_nearest_half_hour( string $date )
Returns as string the nearest half a hour for a given valid string datetime.
Contents
Parameters
- $date
-
(string) (Required) Valid DateTime string.
Return
(string) Rounded datetime string
Source
File: src/Tribe/Date_Utils.php
public static function round_nearest_half_hour( $date ) {
$date_object = static::build_date_object( $date );
$rounded_minutes = floor( $date_object->format( 'i' ) / 30 ) * 30;
return $date_object->format( 'Y-m-d H:' ) . $rounded_minutes . ':00';
}
Changelog
| Version | Description |
|---|---|
| 4.10.2 | Introduced. |