PHP code example of laralabs / timezone

1. Go to this page and download the library: Download laralabs/timezone 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/ */

    

laralabs / timezone example snippets


$date = '2018-09-11 11:00:00';
$result = timezone()->fromStorage($date);
$result->formatToDefault();

Output: 11/09/2018 12:00:00

$date = '11/09/2018 12:00:00';
$result = timezone()->toStorage($date);

Output: 2018-09-11 11:00:00

$toTimezone = 'Europe/London';
timezone()->fromStorage($date, $toTimezone);

$fromTimezone = 'Europe/London';
timezone()->toStorage($date, $fromTimezone);

php artisan vendor:publish --tag=timezone-config