PHP Class Knp\Bundle\TimeBundle\DateTimeFormatter

Show file Open project: KnpLabs/KnpTimeBundle Class Usage Examples

Protected Properties

Property Type Description
$translator

Public Methods

Method Description
__construct ( Symfony\Component\Translation\TranslatorInterface $translator ) Constructor
formatDiff ( DateTimeInterface $from, DateTimeInterface $to ) : string Returns a formatted diff for the given from and to datetimes
getDiffMessage ( integer $count, boolean $invert, integer $unit ) : string Returns the diff message for the specified count and unit
getEmptyDiffMessage ( ) : string Returns the message for an empty diff

Protected Methods

Method Description
doGetDiffMessage ( $count, $invert, $unit )

Method Details

__construct() public method

Constructor
public __construct ( Symfony\Component\Translation\TranslatorInterface $translator )
$translator Symfony\Component\Translation\TranslatorInterface Translator used for messages

doGetDiffMessage() protected method

protected doGetDiffMessage ( $count, $invert, $unit )

formatDiff() public method

Returns a formatted diff for the given from and to datetimes
public formatDiff ( DateTimeInterface $from, DateTimeInterface $to ) : string
$from DateTimeInterface
$to DateTimeInterface
return string

getDiffMessage() public method

Returns the diff message for the specified count and unit
public getDiffMessage ( integer $count, boolean $invert, integer $unit ) : string
$count integer The diff count
$invert boolean Whether to invert the count
$unit integer The unit must be either year, month, day, hour, minute or second
return string

getEmptyDiffMessage() public method

Returns the message for an empty diff
public getEmptyDiffMessage ( ) : string
return string

Property Details

$translator protected property

protected $translator