定制 org_heigl/date-formatter 二次开发

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

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

org_heigl/date-formatter

Composer 安装命令:

composer require org_heigl/date-formatter

包简介

Extendable Library to format DateTimes using Zend-Frameworks Date-Constants

README 文档

README

Build Status Code Climate Test Coverage Scrutinizer Code Quality

Extendable Library to format DateTimes using Zend-Frameworks Date-Constants

Installation

composer require org_heigl/date-formatter

Usage

use Org_Heigl\DateFormatter\FormatterFacade as Formatter;

$date = new DateTime('2013-12-03 12:23:34', new DateTimeZone('Europe/Berlin'));

echo Formatter::format($date, 'PDF');
// Prints "20131203122334+01'00'"

Currently the following formatters are available:

  • PDF
  • ATOM
  • COOKIE
  • RFC_822
  • RFC_850
  • RFC_1036
  • RFC_1123
  • RFC_3339
  • RSS
  • W3C
  • MYSQL

Extending

You can add your own formatter by creating a class that implements the Org_Heigl\DateFormatter\Formatter\FormatterInterface. This class can then either be used directly like in this example:

use Org_Heigl\DateFormatter\DateFormatter as Formatter;

$formatter = new Formatter(new MyCoolClassImplementingFormatterInterface());

$date = new DateTime('2013-12-03 12:23:34', new DateTimeZone('Europe/Berlin'));

echo $formatter->format($date);
// Prints whatever you formatted the given date to ;)

To be able to use it with the FormatterFacade you have to announce the Folder containing the formatter to the class like in this example:

use Org_Heigl\DateFormatter\FormatterFacade as Formatter;

// Announce the Folder containing your formatter to the class
Formatter::addFormatterFolder('/absolute/Path/To/Your/Formatter/Folder');

$date = new DateTime('2013-12-03 12:23:34', new DateTimeZone('Europe/Berlin'));

echo Formatter::format($date, 'WhateverYouCalledYourFormatter');
// Prints WhateverYourFormatterDoes ;)

Self-Defined formatters will always be called instead of default formatters. So when you have a formatter for "PDF" in your added folder that formatter will be called instead of the default formatter!

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-03-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固