承接 oat-sa/lib-tao-dtms 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

oat-sa/lib-tao-dtms

最新稳定版本:v1.0.2

Composer 安装命令:

composer require oat-sa/lib-tao-dtms

包简介

Classes for manipulate dates and intervals with microseconds precision

README 文档

README

DateTime and DateInterval classes with support of microseconds

NOTE! This package not fully tested, so use it with caution.

This small package with two classes just wrapper around built in PHP classes for work with date and time but with support operations with microseconds.

Installation

Package use PSR-4 standard, so for using this classes just install package using Composer.

$ composer require oat-sa/lib-tao-dtms
{
    "require": {
        "oat-sa/lib-tao-dtms": "~0.5"
    }
}
<?php
require 'vendor/autoload.php';

use oat\dtms\DateTime;
use oat\dtms\DateInterval;

Usage

After installation you can create DateTime instances with microseconds.

$dt = new DateTime('2015-08-08 10:10:10.123456');
echo $dt->format('Y-m-d H:i:s.u'); // 2015-08-08 10:10:10.123456

Also you can modify DateTime with microseconds. Supported words "microseconds", "microsecond", "micro", "mic".

$dt = new DateTime('2015-08-08 10:10:10.123456');
$dt->modify('123456 micro');
echo $dt->format('u'); // 246912

And of course this package allow usage true ISO8601 format for date intervals with microseconds.

$interval = new DateInterval('PT2.2S');
echo $interval->format('PT%sS'); // PT2.200000S 

Class DateTime support standard methods, such as add, sub, diff, format etc.

For using native DateTime and DateInteval classes together with package use root namespace for it:

$uDateTime = new DateTime(); // DateTime from package
$nativeDateTime = new \DateTime(); // built in DateTime

Note! Current package may work incorrectly with different time zones, so it need extra check and more tests.

If you found error or weird behavior, send me issue report, please.

Credits

Developed by Ivan Klimchuk for Open Assessment Technologies S.A.

License

The GPLv2. Please see LICENSE for more information.

统计信息

  • 总下载量: 93.23k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 2
  • 依赖项目数: 4
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 48
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0-only
  • 更新时间: 2015-10-19