mirror of
https://github.com/beestat/app.git
synced 2025-06-02 13:18:27 -04:00
Made some date conversion functions a bit more generic.
This commit is contained in:
parent
9e621fb335
commit
bea4afced0
@ -829,13 +829,13 @@ class runtime extends cora\api {
|
|||||||
*
|
*
|
||||||
* @return string The UTC datetime string.
|
* @return string The UTC datetime string.
|
||||||
*/
|
*/
|
||||||
private function get_utc_datetime($local_datetime, $local_time_zone) {
|
private function get_utc_datetime($local_datetime, $local_time_zone, $format = 'Y-m-d H:i:s') {
|
||||||
$local_time_zone = new DateTimeZone($local_time_zone);
|
$local_time_zone = new DateTimeZone($local_time_zone);
|
||||||
$utc_time_zone = new DateTimeZone('UTC');
|
$utc_time_zone = new DateTimeZone('UTC');
|
||||||
$date_time = new DateTime($local_datetime, $local_time_zone);
|
$date_time = new DateTime($local_datetime, $local_time_zone);
|
||||||
$date_time->setTimezone($utc_time_zone);
|
$date_time->setTimezone($utc_time_zone);
|
||||||
|
|
||||||
return $date_time->format('Y-m-d H:i:s');
|
return $date_time->format($format);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -846,13 +846,13 @@ class runtime extends cora\api {
|
|||||||
*
|
*
|
||||||
* @return string The UTC datetime string.
|
* @return string The UTC datetime string.
|
||||||
*/
|
*/
|
||||||
private function get_local_datetime($utc_datetime, $local_time_zone) {
|
private function get_local_datetime($utc_datetime, $local_time_zone, $format = 'Y-m-d H:i:s') {
|
||||||
$local_time_zone = new DateTimeZone($local_time_zone);
|
$local_time_zone = new DateTimeZone($local_time_zone);
|
||||||
$utc_time_zone = new DateTimeZone('UTC');
|
$utc_time_zone = new DateTimeZone('UTC');
|
||||||
$date_time = new DateTime($utc_datetime, $utc_time_zone);
|
$date_time = new DateTime($utc_datetime, $utc_time_zone);
|
||||||
$date_time->setTimezone($local_time_zone);
|
$date_time->setTimezone($local_time_zone);
|
||||||
|
|
||||||
return $date_time->format('Y-m-d H:i:s');
|
return $date_time->format($format);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user