PHPackages                             ppeerit/time - 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. ppeerit/time

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

ppeerit/time
============

time library

v1.1.1(9y ago)027MITPHPPHP &gt;=5.4.0

Since Apr 9Pushed 9y ago1 watchersCompare

[ Source](https://github.com/ppeerit/time)[ Packagist](https://packagist.org/packages/ppeerit/time)[ Docs](https://github.com/ppeerit/time)[ RSS](/packages/ppeerit-time/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (3)DependenciesVersions (4)Used By (0)

简单的时间戳操作库
=========

[](#简单的时间戳操作库)

用于获取各种类型时间戳

使用
==

[](#使用)

安装
--

[](#安装)

```
composer require ppeerit/time
```

引入命名空间
------

[](#引入命名空间)

```
use Ppeerit/Time/Time
```

方法
==

[](#方法)

今天开始和结束的时间戳
-----------

[](#今天开始和结束的时间戳)

```
// 返回一个数组['开始时间戳','结束时间戳']
list($start_time, $end_time) = Time::today();
```

昨日开始和结束的时间戳
-----------

[](#昨日开始和结束的时间戳)

```
// 返回一个数组['开始时间戳','结束时间戳']
list($start_time, $end_time) = Time::yesterday();
```

明天开始和结束的时间戳
-----------

[](#明天开始和结束的时间戳)

```
// 返回一个数组['开始时间戳','结束时间戳']
list($start_time, $end_time) = Time::tomorrow();
```

本周开始和结束的时间戳
-----------

[](#本周开始和结束的时间戳)

```
// 返回一个数组['开始时间戳','结束时间戳']
list($start_time, $end_time) = Time::week();
```

上周开始和结束的时间戳
-----------

[](#上周开始和结束的时间戳)

```
// 返回一个数组['开始时间戳','结束时间戳']
list($start_time, $end_time) = Time::lastWeek();
```

下周开始和结束的时间戳
-----------

[](#下周开始和结束的时间戳)

```
// 返回一个数组['开始时间戳','结束时间戳']
list($start_time, $end_time) = Time::nextWeek();
```

本月开始和结束的时间戳
-----------

[](#本月开始和结束的时间戳)

```
// 返回一个数组['开始时间戳','结束时间戳']
list($start_time, $end_time) = Time::month();
```

上个月开始和结束的时间戳
------------

[](#上个月开始和结束的时间戳)

```
// 返回一个数组['开始时间戳','结束时间戳']
list($start_time, $end_time) = Time::lastMonth();
```

下个月开始和结束的时间戳
------------

[](#下个月开始和结束的时间戳)

```
// 返回一个数组['开始时间戳','结束时间戳']
list($start_time, $end_time) = Time::nextMonth();
```

今年开始和结束的时间戳
-----------

[](#今年开始和结束的时间戳)

```
// 返回一个数组['开始时间戳','结束时间戳']
list($start_time, $end_time) = Time::year();
```

去年开始和结束的时间戳
-----------

[](#去年开始和结束的时间戳)

```
// 返回一个数组['开始时间戳','结束时间戳']
list($start_time, $end_time) = Time::lastYear();
```

明年开始和结束的时间戳
-----------

[](#明年开始和结束的时间戳)

```
// 返回一个数组['开始时间戳','结束时间戳']
list($start_time, $end_time) = Time::nextYear();
```

N天前的时间戳
-------

[](#n天前的时间戳)

```
// 返回一个时间戳
$days = 10; // 本例定义为10天
$time = Time::daysAgo($days); // 返回10天前的时间戳
```

N天后的时间戳
-------

[](#n天后的时间戳)

```
// 返回一个时间戳
$days = 10; // 本例定义为10天
$time = Time::daysAfter($days); // 返回10天后的时间戳
```

天数转换成秒数
-------

[](#天数转换成秒数)

```
// 返回一个数字
$days = 10; // 本例定义为10天
$seconds = Time::daysToSecond($days); // 返回10天共多少秒
```

周数转换成秒数
-------

[](#周数转换成秒数)

```
// 返回一个数字
$weeks = 2; // 本例定义为2周
$seconds = Time::weeksToSecond($weeks); // 返回2周共多少秒
```

### 更多方法完善中

[](#更多方法完善中)

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

3

Last Release

3369d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/bc9ac0baa4a9380596619d9c5d630cb6601f7d0d1b59b8e010179eaadfb154e7?d=identicon)[zewail](/maintainers/zewail)

---

Top Contributors

[![czewail](https://avatars.githubusercontent.com/u/14213748?v=4)](https://github.com/czewail "czewail (14 commits)")

---

Tags

time

### Embed Badge

![Health badge](/badges/ppeerit-time/health.svg)

```
[![Health](https://phpackages.com/badges/ppeerit-time/health.svg)](https://phpackages.com/packages/ppeerit-time)
```

###  Alternatives

[symfony/clock

Decouples applications from the system clock

434192.7M340](/packages/symfony-clock)[knplabs/knp-time-bundle

Making your dates and durations look sensible and descriptive

6239.3M52](/packages/knplabs-knp-time-bundle)[league/period

Time range API for PHP

7335.7M22](/packages/league-period)[wapmorgan/morphos

A morphological solution for Russian and English language written completely in PHP. Provides classes to inflect personal names, geographical names, decline and pluralize nouns, generate cardinal and ordinal numerals, spell out money amounts and time.

8261.3M7](/packages/wapmorgan-morphos)[brick/date-time

Date and time library

3623.6M94](/packages/brick-date-time)[aeon-php/calendar

PHP type safe, immutable calendar library

20410.2M16](/packages/aeon-php-calendar)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
