filmtools/secondstominutes

将秒转换为 'mm:ss' 或 'hh:mm:ss' 格式

1.0.1 2019-04-23 21:42 UTC

This package is auto-updated.

Last update: 2024-09-24 09:59:24 UTC


README

将秒转换为 'mm:ss' 或 'hh:mm:ss' 格式

Build Status Scrutinizer Code Quality Code Coverage Build Status

安装

$ composer require filmtools/secondstominutes

使用

seconds2minutes 函数是命名空间的,所以在你的 use 语句中必须提及它。可调用类 SecondsToMinutes 是该函数的包装器;它可以作为 Twig 过滤器 使用。

use function FilmTools\SecondsToMinutes\seconds2minutes;
use FilmTools\SecondsToMinutes\SecondsToMinutes;

echo seconds2minutes( 3900 ); // "01:05:00"

$formatter = new SecondsToMinutes;
echo $formatter( 90 ); // "01:30"

$filter = new \Twig\TwigFilter('secondstominutes', new SecondsToMinutes);
$twig->addFilter( $filter );

开发和单元测试

$ git clone https://github.com/filmtools/secondstominutes.git
$ cd secondstominutes
$ composer install

# either, or, and:
$ composer phpunit
$ vendor/bin/phpunit