PHP code example of rxlisbest / php-date

1. Go to this page and download the library: Download rxlisbest/php-date library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

rxlisbest / php-date example snippets

$xslt
composer 
$xslt
$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
$xslt
$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
$xslt
$timestamp = 1527729723; // 2018-05-31 09:22:03
$month = (new PhpDate($timestamp))->month;
$month->diff('2018-06-01'); // 1