PHP code example of ppeerit / time
1. Go to this page and download the library: Download ppeerit/time 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/ */
ppeerit / time example snippets
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();
// 返回一个时间戳
$days = 10; // 本例定义为10天
$time = Time::daysAgo($days); // 返回10天前的时间戳
// 返回一个时间戳
$days = 10; // 本例定义为10天
$time = Time::daysAfter($days); // 返回10天后的时间戳
// 返回一个数字
$days = 10; // 本例定义为10天
$seconds = Time::daysToSecond($days); // 返回10天共多少秒
// 返回一个数字
$weeks = 2; // 本例定义为2周
$seconds = Time::weeksToSecond($weeks); // 返回2周共多少秒