PHPackages                             reply/microtime - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. reply/microtime

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

reply/microtime
===============

Microtime library

2.0.2(4y ago)225.7k1MITPHPPHP ^7.1CI failing

Since May 14Pushed 4y ago1 watchersCompare

[ Source](https://github.com/PortaltechGithub/microtime)[ Packagist](https://packagist.org/packages/reply/microtime)[ RSS](/packages/reply-microtime/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (5)Used By (0)

Microtime
=========

[](#microtime)

Microtime is a library written in pure PHP that provides an interface and a class to work with microseconds. PHP offers the possibility to get the current timestamp in seconds and microseconds via the [microtime()](https://www.php.net/microtime) function, but the resulting two values must always be converted so that the number of microseconds since the unix epoch is obtained. The Microtime class does this work for you. This allows you to create a Microtime object from different formats and convert it into different formats like [DateTime](https://www.php.net/datetime) object, integer and string.

Requirements
------------

[](#requirements)

Microtime requires the following:

- PHP 7.1 or higher

Installation
------------

[](#installation)

Microtime is installed via [Composer](https://getcomposer.org/). To [add a dependency](https://getcomposer.org/doc/04-schema.md#package-links) to Microtime in your project, either

Run the following to use the latest stable version

```
    composer require reply/microtime
```

or if you want the latest master version

```
    composer require reply/microtime:dev-master
```

You can of course also manually edit your composer.json file

```
{
    "require": {
       "reply/microtime": "^2.0"
    }
}
```

Getting started
---------------

[](#getting-started)

The following is a basic usage example of the Microtime library:

```
