time: Implement ConvertableTimestamp::now()
authorKunal Mehta <legoktm@member.fsf.org>
Thu, 22 Sep 2016 03:28:42 +0000 (20:28 -0700)
committerKunal Mehta <legoktm@member.fsf.org>
Thu, 22 Sep 2016 04:26:18 +0000 (21:26 -0700)
Shortcut for ConvertableTimestamp::convert() for the current time.

Change-Id: I1c34c0a59bb57652c7a2e959836c8ba400a25f49

includes/GlobalFunctions.php
includes/libs/time/ConvertableTimestamp.php

index 0360d19..6e8ce8f 100644 (file)
@@ -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 );
 }
 
 /**
index a4c79ba..a784dc6 100644 (file)
@@ -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.
         *