2017 © Pedro Peláez
 

library php-dot-net-ticks

This package helps PHP developers work with and convert .NET ticks, a form of precise time measurement used by the .NET DateTime object.

image

divineomega/php-dot-net-ticks

This package helps PHP developers work with and convert .NET ticks, a form of precise time measurement used by the .NET DateTime object.

  • Friday, March 9, 2018
  • by DivineOmega
  • Repository
  • 1 Watchers
  • 1 Stars
  • 3 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 50 % Grown

The README.md

⏱ PHP .NET Ticks

Build Status Coverage Status StyleCI, (*1)

This package helps PHP developers work with and convert .NET ticks, a form of precise time measurement used by the .NET DateTime object., (*2)

Features

You can use this library to do the following, and more., (*3)

  • Convert ticks to timestamp
  • Convert ticks to DateTime object
  • Convert ticks to Carbon date object
  • Get the current time in ticks
  • Convert timestamp to ticks

What are .NET ticks?

A single tick represents one hundred nanoseconds or one ten-millionth of a second. There are 10,000 ticks in a millisecond, or 10 million ticks in a second., (*4)

The value of this property [DateTime.Ticks] represents the number of 100-nanosecond intervals that have elapsed since 12:00:00 midnight, January 1, 0001 (0:00:00 UTC on January 1, 0001, in the Gregorian calendar), which represents DateTime.MinValue. It does not include the number of ticks that are attributable to leap seconds., (*5)

Source: .NET API Reference: DateTime.Tick Property, (*6)

Installation

The PHP .NET Ticks package can be easily installed using Composer. Just run the following command from the root of your project., (*7)

composer require divineomega/php-dot-net-ticks

If you have never used the Composer dependency manager before, head to the Composer website for more information on how to get started., (*8)

Usage

First you need to create a new Ticks object. This can be done in several ways., (*9)

use DivineOmega\DotNetTicks\Ticks;

// Current time
$ticks = new Ticks();

// Specific time in ticks
$ticks = new Ticks(636536021491253348);

// From timestamp
$ticks = Ticks::createFromTimestamp(1518005349);

You can then call methods on the Ticks object to retrieve or convert as necessary., (*10)

$ticks = $ticks->ticks();       // Ticks

$time = $ticks->timestamp();    // UNIX timstamp

$dateTime = $ticks->dateTime(); // PHP DateTime object
$carbon = $ticks->carbon();     // Carbon date object

If you wish, you can combine these two steps into one line, as shown in the examples below., (*11)

// Get current time in ticks
$nowInTicks = (new Ticks())->ticks();

// Convert ticks to timestamp
$timestamp = (new Ticks(636536021491253348))->timestamp();

// Convert timestamp to ticks
$ticks = Ticks::createFromTimestamp(1518005349)->ticks();

The Versions

09/03 2018

dev-master

9999999-dev

This package helps PHP developers work with and convert .NET ticks, a form of precise time measurement used by the .NET DateTime object.

  Sources   Download

LGPL-3.0-only

The Requires

 

The Development Requires

by Jordan Hall

13/02 2018

dev-analysis-86DLl6

dev-analysis-86DLl6

This package helps PHP developers work with and convert .NET ticks, a form of precise time measurement used by the .NET DateTime object.

  Sources   Download

LGPL-3.0-only

The Requires

 

The Development Requires

by Jordan Hall

07/02 2018

v1.0.0

1.0.0.0

  Sources   Download

LGPL-3.0-only

The Requires

 

The Development Requires

by Jordan Hall