i18n\Formatter asDuration()

asDuration() public method (available since version 2.0.7)

Represents the value as duration in human readable format.

public string asDuration ( $value, $implodeString = ', ', $negativeSign = '-' )
$value DateInterval|string|integer

The value to be formatted. Acceptable formats:

  • DateInterval object
  • integer - number of seconds. For example: value 131 represents 2 minutes, 11 seconds
  • ISO8601 duration format. For example, all of these values represent 1 day, 2 hours, 30 minutes duration: 2015-01-01T13:00:00Z/2015-01-02T13:30:00Z - between two datetime values 2015-01-01T13:00:00Z/P1D2H30M - time interval after datetime value P1D2H30M/2015-01-02T13:30:00Z - time interval before datetime value P1D2H30M - simply a date interval P-1D2H30M - a negative date interval (-1 day, 2 hours, 30 minutes)
$implodeString string

Will be used to concatenate duration parts. Defaults to , .

$negativeSign string

Will be prefixed to the formatted duration, when it is negative. Defaults to -.

return string

The formatted duration.

doc_Yii
2016-10-30 17:05:58
Comments
Leave a Comment

Please login to continue.