robier/date
Composer 安装命令:
composer require robier/date
包简介
Simple date implementation of ISO 8601 standard
README 文档
README
Simple date implementation of ISO 8601 standard.
Introduction
The Date class follows the ISO 8601 standard for representing date.
Also allows easy getting range of two dates.
Installation
You can install this library with composer.
composer require robier/date
Requirements
This library requires PHP 7.1.
Overview
This library contains of 3 classes:
Date- representation of actual dateDate\Factory- factory for creatingDateobject in different waysDate\Range- generator that represents range between 2 dates
Samples
Creating new instance of Date (various ways how to get date 1991-11-14):
use Robier\Date; $date = new Date(1991, 11, 14); // or $date = Date/Factory::new(1991, 11, 14); // or $date = Date/Factory::dateTime(DateTime::createFromFormat('Y-m-d', '1991-11-14')); // or $date = Date/Factory::string('1991-11-14'); // or $date = Date/Factory::iso(1991, 46, 4);
Get today date:
$today = Date/Factory::today();
Get tomorrows date:
$tomorrow = Date/Factory::tomorrow(); // or $tomorrow = Date/Factory::today()->next();
Get yesterday date:
$yesterday = Date/Factory::yesterday(); // or $yesterday = Date/Factory::today()->previous();
Get any date in future of provided date (ie. 5 days after 1991-11-14):
$date = new Date(1991, 11, 14); $date->next(5);
Get any date in past of provided date (ie. 6 days before 1991-11-14):
$date = new Date(1991, 11, 14); $date->previous(6);
Range between 2 dates (ie. get dates between 1991-11-14 and 1991-12-01):
$start = new Date(1991, 11, 14); $end = new Date(1991, 12, 1); $range = new Date\Range($start, $end); // or $range = $start->to($end);
统计信息
- 总下载量: 248
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-08-03