定制 mareg/rough-date 二次开发

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

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

mareg/rough-date

最新稳定版本:1.0.6

Composer 安装命令:

composer require mareg/rough-date

包简介

Rough date object allowing dates like `Jan 2005` or `2006`

README 文档

README

Needed to store a "rough date" in one of my project, may be useful for otheres.

CI Build Status Scrutinizer Code Quality License: GPL v3

Installation

Execute from shell the following command:

$ composer require mareg/rough-date

Or add "mareg/rough-date": "^1.0" to your composer.json:

    "require": {
        "mareg/rough-date": "^1.0"
    },

Usage

Create a RoughDate object from the string:

$roughDate = RoughDate::fromString('May 2005');
echo $roughDate->format();

Or from a DateTime date object:

$date = new \DateTime();
$roughDate = RoughDate::fromDateTime($date);
echo $roughDate->format();

Accepted date formats

When creating an object through RoughDate::fromString():

  • Y-m-d, e.g. 2015-02-22, but also 2013-05-00 and 2013-00-00 are correct
  • Y/m/d and Y.m.d are accepted
  • j. M Y, e.g. 13. May 2005
  • M Y, e.g. May 1985
  • Y, e.g. 1978

Output date formats

When calling RoughDate::format():

  • For a full date output accepts all variables as in date() method
  • For other dates only available variables will be substituded and unavailable ones will be removed, e.g.:
  • for date 2015-02-00 and format j M Y you'll get Feb 2015
  • for date 1978-00-00 and format j M Y you'll get 1978

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-3.0-only
  • 更新时间: 2015-02-22