From 9aae1b7fc399b5d2cecb8f0d0df6a2ae4e749786 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak <alec@alec.pl> Date: Fri, 26 Jun 2015 03:20:43 -0400 Subject: [PATCH] Fix so microseconds macro (u) in log_date_format works (#1490446) --- program/lib/Roundcube/rcube_utils.php | 23 +++++++++++++++++++++++ 1 files changed, 23 insertions(+), 0 deletions(-) diff --git a/program/lib/Roundcube/rcube_utils.php b/program/lib/Roundcube/rcube_utils.php index 00311f0..23fc3f8 100644 --- a/program/lib/Roundcube/rcube_utils.php +++ b/program/lib/Roundcube/rcube_utils.php @@ -1149,4 +1149,27 @@ return $random; } + + /** + * Format current date according to specified format. + * This method supports microseconds (u). + * + * @param string $format Date format (default: 'd-M-Y H:i:s O') + * + * @return string Formatted date + */ + public static function date_format($format = null) + { + if (empty($format)) { + $format = 'd-M-Y H:i:s O'; + } + + if (strpos($format, 'u') !== false + && ($date = date_create_from_format('U.u.e', microtime(true) . '.' . date_default_timezone_get())) + ) { + return $date->format($format); + } + + return date($format); + } } -- Gitblit v1.9.1