定制 pavel-krush/duration 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

pavel-krush/duration

最新稳定版本:v1.0.0

Composer 安装命令:

composer require pavel-krush/duration

包简介

PHP implementation of GoLang time.Duration

README 文档

README

PHP implementation of GoLang's time.Duration

The code is mostly ported from GoLang source code. See time/format.go and time/time.go

Setup

Ensure you have composer installed, then run the following command:

composer require pavel-krush/duration

That will fetch the library inside your vendor folder. Then you can add the following to your .php files in order to use the library:

require_once __DIR__.'/vendor/autoload.php';

Usage

To parse string containing duration use Parser class:

$d = \PavelKrush\Duration\Parser::fromString("13h10m21s");
print $d->Hours() . "\n"; // 13.345
print $d->Minutes() . "\n"; // 790.7
print $d->Seconds() . "\n"; // 47421
print $d->Round(new \PavelKrush\Duration\Duration(\PavelKrush\Duration\Duration::Minute)); // 13h10m0s 

统计信息

  • 总下载量: 1.22k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-09-29