PHPackages                             rxlisbest/php-date - 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. rxlisbest/php-date

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

rxlisbest/php-date
==================

php 各种日期获取

1.2.2(6y ago)25263MITPHP

Since May 20Pushed 3y ago1 watchersCompare

[ Source](https://github.com/rxlisbest/php-date)[ Packagist](https://packagist.org/packages/rxlisbest/php-date)[ RSS](/packages/rxlisbest-php-date/feed)WikiDiscussions master Synced 4d ago

READMEChangelogDependencies (2)Versions (6)Used By (0)

php-date
========

[](#php-date)

安装
--

[](#安装)

```
composer require rxlisbest/php-date

```

用法
--

[](#用法)

#### 1、当前时间点

[](#1当前时间点)

```
$timestamp = 1558176210; // 2019-05-18 18:43:30

// 周
$week = (new PhpDate($timestamp))->week;
$week->today(); // 2019-05-18
$week->begin(); // 2019-05-12
$week->end(); // 2019-05-18
$week->sunday(); // 2019-05-13
$week->monday(); // 2019-05-14
$week->tuesday(); // 2019-05-15
$week->wednesday(); // 2019-05-16
$week->friday(); // 2019-05-17
$week->saturday(); // 2019-05-18

// 我们的周习惯，周一是一周第一天
$chineseWeek = (new PhpDate($timestamp))->chineseWeek;
$chineseWeek->today(); // 2019-05-18
$chineseWeek->begin(); // 2019-05-13
$chineseWeek->end(); // 2019-05-19
$chineseWeek->monday(); // 2019-05-14
$chineseWeek->tuesday(); // 2019-05-15
$chineseWeek->wednesday(); // 2019-05-16
$chineseWeek->friday(); // 2019-05-17
$chineseWeek->saturday(); // 2019-05-18
$chineseWeek->sunday(); // 2019-05-19

// 月
$month = (new PhpDate($timestamp))->month;
$month->today(); // 2019-05-18
$month->begin(); // 2019-05-01
$month->end(); // 2019-05-31

// 年
$year = (new PhpDate($timestamp))->year;
$year->today(); // 2019-05-18
$year->begin(); // 2019-01-01
$year->end(); // 2019-12-31

// 季度
$quarter = (new PhpDate($timestamp))->quarter;
$quarter->today(); // 2019-05-18
$quarter->begin(); // 2019-04-01
$quarter->end(); // 2019-06-30

```

#### 2、当前时间点 向前/向后 推移（以月为例，年、季度、周同月）

[](#2当前时间点-向前向后-推移以月为例年季度周同月)

```
$timestamp = 1527729723; // 2018-05-31 09:22:03
$month = (new PhpDate($timestamp))->month;
$month->next()->today(); // 2019-06-30
$month->next(2)->today(); // 2019-07-31
$month->next(3)->today(); // 2019-08-31

$month->last()->today(); // 2019-04-30
$month->last(2)->today(); // 2019-03-31
$month->last(3)->today(); // 2019-02-28

```

说明：如果向前/向后的周期内天数小于当前日期天数，则取周期的最后一天

#### 3、输出格式化（以月为例，年、季度、周同月）

[](#3输出格式化以月为例年季度周同月)

```
$timestamp = 1527729723; // 2018-05-31 09:22:03
$month = (new PhpDate($timestamp))->month;
$month->format('Y-m-d H:i:s')->today(); // 2018-05-31 09:22:03

```

说明：格式化参数格式同date函数第一个参数

#### 4、两个日期的间隔（以月为例，年、季度、周同月）

[](#4两个日期的间隔以月为例年季度周同月)

```
$timestamp = 1527729723; // 2018-05-31 09:22:03
$month = (new PhpDate($timestamp))->month;
$month->diff('2018-06-01'); // 1

```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity63

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 ~8 days

Total

5

Last Release

2521d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/62300e760338350c94e0b2d321deabf9145ca5969662dc95dc191a4ae402bf13?d=identicon)[rxlisbest](/maintainers/rxlisbest)

---

Top Contributors

[![rxlisbest](https://avatars.githubusercontent.com/u/4598303?v=4)](https://github.com/rxlisbest "rxlisbest (68 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/rxlisbest-php-date/health.svg)

```
[![Health](https://phpackages.com/badges/rxlisbest-php-date/health.svg)](https://phpackages.com/packages/rxlisbest-php-date)
```

###  Alternatives

[ckfinder/ckfinder-laravel-package

CKFinder 3 package for Laravel

159497.2k48](/packages/ckfinder-ckfinder-laravel-package)[jaxon-php/jaxon-core

Jaxon is an open source PHP library for easily creating Ajax web applications

73142.3k25](/packages/jaxon-php-jaxon-core)[ckfinder/ckfinder-symfony-bundle

CKFinder bundle for Symfony

42435.7k](/packages/ckfinder-ckfinder-symfony-bundle)[inpsyde/wp-app-container

DI Container and related tools to be used at website level.

41253.5k](/packages/inpsyde-wp-app-container)[rockettheme/toolbox

RocketTheme Toolbox Library

22526.9k3](/packages/rockettheme-toolbox)[rochamarcelo/cake-pimple-di

A cakephp plugin for dependency injection based on Pimple library

12176.8k](/packages/rochamarcelo-cake-pimple-di)

PHPackages © 2026

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