PHP code example of kibatic / timezone-bundle

1. Go to this page and download the library: Download kibatic/timezone-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

kibatic / timezone-bundle example snippets


/** @var \DateTimeInterface $date */
$date = new \DateTimeImmutable();

$tzAdjuster = $container->get('kibatic_timezone.adjuster');
$dateTimeImmutable = $tzAdjuster->asDateTimeImmutable($date);
$dateTime = $tzAdjuster->asDateTime($date);

$date = new \DateTime('2019-10-03T15:28:06.256+02:00');
$dateModified = AdjusterUtil::changeTimezone($date, new \DateTimeZone('GMT+0'));
yml
kibatic_timezone:
    default_display_timezone: "Europe/Paris"    # mandatory
    timezone_provider: "App\\Timezone\\MyTimezoneProvider"   # optional
twig
<div>Timezone : {{ timezoneAdjuster.displayTimezone().name }}</div>

{# convertir un datetime en datetime avec la bone timezone #}
{{ timezoneAdjuster.asDateTime(date) }}