定制 natedrake/datehelper 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

natedrake/datehelper

最新稳定版本:v1.0.0

Composer 安装命令:

composer require natedrake/datehelper

包简介

Date manipulation and output

README 文档

README

Build Status Latest Stable Version Latest Unstable Version License composer.lock

Total Downloads Monthly Downloads Daily Downloads

Manipulate PHP Date

Install

To install this package add it as a dependency using composer

composer.json

"require": {
    "natedrake/datehelper": "^0.1.4"
}

Usage

<?php

use Natedrake\DateHelper\Date;
use Natedrake\DateHelper\DateFormat;

$datePosted=date('2015-08-02 10:36:15');
$date=Date::get()->getDifferenceFromNow($datePosted);

returns the amount of time since the date provided in date posted.
E.g. 10 seconds ago, less than a minute ago, a week ago, 3 weeks ago, a fortnight ago, etc

Classes

Natedrake\DateHelper\Date

Usage:
$ordinal=Date::<function>([parameter]);
Example:
$ordinal=Date::ordinal(12);

returns '12th'

Methods:
Date::differenceFromNow($date);

returns the difference since the provided date. E.g 10 seconds ago, a week ago, a fortnight, ago, 3 weeks ago, etc

Date::ordinal($number);

returns the ordinal for the number provided. E.g. 1st, 10th, 3rd, etc.

Natedrake\DateHelper\DateFormat

Usage:
DateFormat::get()->date(<date>)-><function>([paramater]);
Example:
$isLeapYear=DateFormat::get()->date('2012-01-01')->isLeapYear();

returns true, or false if year of date isn't a leap year

Methods:
DateFormat::get();

returns a DateFormat object to use

DateFormat::get()->date($date);

set the date of the date format object

DateFormat::get()->date($date)->format('Y-m-d H:i:s);

returns the date in the provided format.

DateFormat::get()->date($date)->format(DateFormat::ISO8601);

There are a list of predefined formats in the DateFormat class.

DateFormat::EASY        *25th of March 2016 09:00:00 AM*
DateFormat::BIG         *2016-03-25 09:00:00*
DateFormat::LITTLE      *25-03-2016 09:00:00*
DateFormat::MIDDLE      *03-25-2016 09:00:00*
DateFormat::ISO8601     *2016-03-25T09:00:00+01:00*
DateFormat::RFC2822     *Fri, 25 Mar 2016 09:00:00 +0100*
DateFormat::EPOCH       *1458892800*

DateFormat::DAY         *Friday*
DateFormat::MNT         *Mar*
DateFormat::YEAR        *2016*

DateFormat::GMT         *+01:00* // Time zone difference from GMT
DateFormat::LEAP        *1*      // Returns 1 if year is a leap year

统计信息

  • 总下载量: 164
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-07-06