From 316b4a404bfbcd91c78e9d3a94e81c69d58a4909 Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Wed, 21 Sep 2016 20:28:42 -0700 Subject: [PATCH] time: Implement ConvertableTimestamp::now() Shortcut for ConvertableTimestamp::convert() for the current time. Change-Id: I1c34c0a59bb57652c7a2e959836c8ba400a25f49 --- includes/GlobalFunctions.php | 2 +- includes/libs/time/ConvertableTimestamp.php | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 0360d19731..6e8ce8f2c8 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -2033,7 +2033,7 @@ function wfTimestampOrNull( $outputtype = TS_UNIX, $ts = null ) { */ function wfTimestampNow() { # return NOW - return MWTimestamp::convert( TS_MW, time() ); + return MWTimestamp::now( TS_MW ); } /** diff --git a/includes/libs/time/ConvertableTimestamp.php b/includes/libs/time/ConvertableTimestamp.php index a4c79babb5..a784dc619b 100644 --- a/includes/libs/time/ConvertableTimestamp.php +++ b/includes/libs/time/ConvertableTimestamp.php @@ -177,6 +177,16 @@ class ConvertableTimestamp { } } + /** + * Get the current time in the given format + * + * @param int $style Constant Output format for timestamp + * @return string + */ + public static function now( $style = TS_MW ) { + return static::convert( $style, time() ); + } + /** * Get the timestamp represented by this object in a certain form. * -- 2.20.1