Giter VIP home page Giter VIP logo

dtms's Introduction

DateTime with Microseconds

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"
    }
}
<?php
require 'vendor/autoload.php';

use alroniks\dtms\DateTime;
use alroniks\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

License

The MIT License (MIT). Please see LICENSE for more information.

dtms's People

Contributors

alroniks avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.