承接 pjkober/datetimeintervalbundle 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

pjkober/datetimeintervalbundle

Composer 安装命令:

composer require pjkober/datetimeintervalbundle

包简介

Symfony PJKoberDateTimeIntervalBundle

README 文档

README

PHP and TWIG functions & filters to convert dates interval to number: secounds, minutes, hours, days. Example usage in TWIG: {{ your_date |days }} if your_date = yesterday the result is -1.

Latest Version Build Status

INSTALLATION & CONFIGURATION

INSTALLATION via Composer

composer require pjkober/datetimeintervalbundle

CONFIGURATION

Register the bundle:

<?php
// app/AppKernel.php
public function registerBundles()
{
    $bundles = array(
        // ...
        new pjkober\datetimeintervalbundle\EinsteDateTimeIntervalBundle(),
    );
    // ...
}

Enable the Service component configuration:

# app/config/services.yml
services:
   date_time_interval_twig_extension:
            class: pjkober\datetimeintervalbundle\Twig\TwigFunctionExtension
            public: false
            tags:
                - { name: twig.extension }

USAGE

In PHP!

<?php
// Use the functions with PHP
echo $view['time']->dateToDays($dateTime); 
// returns something like "10" or "-10", count days interval between $dateTime and now

echo $view['time']->dateToDays($dateTime1, $dateTime1); 
// count days interval between $dateTime1 and  $dateTime2

echo $view['time']->dateToHours($dateTime); 
// returns something like "24" or "-36", count interval between $dateTime and now
echo $view['time']->dateToHours($dateTime1, $dateTime1); 
// count hours interval between $dateTime1 and  $dateTime2

echo $view['time']->dateToMinutes($dateTime); 
// returns something like "1140" or "-1140" minutunt interval between $dateTime and now
echo $view['time']->dateToMinutes($dateTime1, $dateTime1); 
// count minutes interval between $dateTime1 and  $dateTime2

echo $view['time']->dateToSeconds($dateTime); 
// returns something like "1140" or "-1140", count interval between $dateTime and now
echo $view['time']-> dateToSeconds($dateTime1, $dateTime1); 
// count Seconds interval between $dateTime1 and  $dateTime2

In Twig!

{{ someDateTime |days }}
{{ someDateTime |hours }}
{{ someDateTime |minutes }}
{{ someDateTime |ceconds }}


//... or use the equivalent function. Secound date is now
{{ dateToDays( date() | date_modify("-1 day")) }}   = 1 
{{ dateToHours( date() | date_modify("-1 day")) }}  = 24
{{ dateToMinutes( date() | date_modify("-1 day")) }}  = 1140
{{ dateToSeconds( date() | date_modify("-1 day")) }}  = 86400

//... or put two dates
 {{ dateToDays( fromDate ,  toDate ) }}
{{ dateToDays( fromDateTime ,  toDateTime ) }}
{{ dateToHours( fromDate ,  toDate ) }}
{{ dateToHours( fromDateTime ,  toDateTime ) }}
{{ dateToMinutes( fromDate ,  toDate ) }}
{{ dateToMinutes( fromDateTime ,  toDateTime ) }}
{{ dateToSeconds( fromDate ,  toDate ) }}
{{ dateToSeconds( fromDateTime ,  toDateTime ) }}

TESTS [x]

If you want to run tests, please check that you have installed dev dependencies.

./vendor/bin/simple-phpunit

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-04-12

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固