jord-jd/php-dot-net-ticks
Composer 安装命令:
composer require jord-jd/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.
README 文档
README
This package helps PHP developers work with and convert .NET ticks, a form of precise time measurement used by the .NET DateTime object.
Features
You can use this library to do the following, and more.
- Convert ticks to timestamp
- Convert ticks to
DateTimeobject - Convert ticks to
Carbondate 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.
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.
Source: .NET API Reference: DateTime.Tick Property
Installation
The PHP .NET Ticks package can be easily installed using Composer. Just run the following command from the root of your project.
composer require jord-jd/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.
Usage
First you need to create a new Ticks object. This can be done in several ways.
use JordJD\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.
$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.
// 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();
jord-jd/php-dot-net-ticks 适用场景与选型建议
jord-jd/php-dot-net-ticks 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1 次下载、GitHub Stars 达 2, 最近一次更新时间为 2026 年 02 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 jord-jd/php-dot-net-ticks 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 jord-jd/php-dot-net-ticks 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 35
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: LGPL-3.0-only
- 更新时间: 2026-02-14