Page tree
Skip to end of metadata
Go to start of metadata

Description


Core\Moment moment( [int $seconds] )


Provides methods that are part of our cores Moment class that deals with time related functions.

Parameters


$seconds

Shorthand call to toString() method, which converts UNIX time to human readable time stamps.

Examples


<?php

route('/foo', function() {

   // Prints the current UNIX time stamp
   $time = moment()->now();

   echo $time;


   // Converts a UNIX time stamp to human readable time (e.g 1 second ago)
   echo moment()->toString($time);
   

   /**
    * Short hand of the toString() method
    */
   echo moment($time);

});

 

Methods


MethodDescriptionUsageReturns

now()

 

Get the current UNIX time stamp.

echo moment()->now();
 
// You can shorthand it as well
echo moment();

Returns current UNIX time stamp.

toString(int $seconds)

 


$seconds

UNIX time stamp

Converts a UNIX time stamp to human readable
time (e.g 1 second ago)

$time = moment()->now();
 
echo moment()->toString($time);

/**
 * Short hand of the toString() method
 */
echo moment($time);

Examples based on time stamp...

  • 1 seconds ago
  • about 4 hours ago
  • 3 days ago
  • January 15, 2015

 

  • No labels