2017 © Pedro Peláez
 

symfony-bundle datetimeintervalbundle

Symfony PJKoberDateTimeIntervalBundle

image

pjkober/datetimeintervalbundle

Symfony PJKoberDateTimeIntervalBundle

  • Wednesday, April 19, 2017
  • by pjkober
  • Repository
  • 0 Watchers
  • 0 Stars
  • 8 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

DateTimeIntervalBundle

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., (*1)

![Latest Version][badge-release] Build Status, (*2)

INSTALLATION & CONFIGURATION

INSTALLATION via Composer

composer require pjkober/datetimeintervalbundle

CONFIGURATION

Register the bundle:, (*3)

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

Enable the Service component configuration:, (*4)

# 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!

``` php {{ someDateTime |days }} {{ someDateTime |hours }} {{ someDateTime |minutes }} {{ someDateTime |ceconds }}, (*5)

//... 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, (*6)

//... 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 ) }}, (*7)


## TESTS [x] If you want to run tests, please check that you have installed dev dependencies. ```bash ./vendor/bin/simple-phpunit

License

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

The Versions

19/04 2017

dev-master

9999999-dev

Symfony PJKoberDateTimeIntervalBundle

  Sources   Download

MIT

The Requires

  • php ^5.5.9 || ^7.0

 

The Development Requires

test phpunit

12/04 2017

v0.5.17

0.5.17.0

Symfony PJKoberDateTimeIntervalBundle

  Sources   Download

MIT

The Requires

  • php ^5.5.9 || ^7.0

 

The Development Requires

test phpunit

12/04 2017

0.5.17

0.5.17.0

Symfony PJKoberDateTimeIntervalBundle

  Sources   Download

MIT

The Requires

  • php ^5.5.9 || ^7.0

 

The Development Requires

test phpunit

12/04 2017

dev-develop

dev-develop

Symfony PJKoberDateTimeIntervalBundle

  Sources   Download

MIT

The Requires

  • php ^5.5.9 || ^7.0

 

The Development Requires

test phpunit