Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

DateTime classes with support of microseconds

License

NotificationsYou must be signed in to change notification settings

alroniks/dtms

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 alroniks/dtms
{"require": {"alroniks/dtms":"~0.5"    }}
<?phprequire'vendor/autoload.php';usealroniks\dtms\DateTime;usealroniks\dtms\DateInterval;

Usage

After installation you can create DateTime instances with microseconds.

$dt =newDateTime('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 =newDateTime('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 =newDateInterval('PT2.2S');echo$interval->format('PT%sS');// PT2.200000S

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

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

$uDateTime =newDateTime();// 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 meissue report, please.

Credits

License

The MIT License (MIT). Please seeLICENSE for more information.

About

DateTime classes with support of microseconds

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp