Skip to content

Instantly share code, notes, and snippets.

@ndm2
Created October 24, 2019 19:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ndm2/df004c19e3eebe5002043a4ab385d278 to your computer and use it in GitHub Desktop.
Save ndm2/df004c19e3eebe5002043a4ab385d278 to your computer and use it in GitHub Desktop.
<?php
ini_set('intl.default_locale', 'pt_BR');
I18n::setLocale('pt_BR');
date_default_timezone_set('America/Sao_Paulo');
Time::setToStringFormat([\IntlDateFormatter::SHORT, \IntlDateFormatter::SHORT]);
$time = Time::now();
debug($time);
debug((string)$time);
debug($time->i18nFormat());
debug($time->i18nFormat('yyyy-MM-dd HH:mm:ss'));
debug($time->format('Y-m-d H:i:s'));
debug($time->getTimezone()->getTransitions(strtotime('2019-01-01'), strtotime('2020-01-01')));
phpinfo(INFO_MODULES);
/*
########## DEBUG ##########
object(Cake\I18n\Time) {
'time' => '2019-10-24T16:51:40-03:00',
'timezone' => 'America/Sao_Paulo',
'fixedNowTime' => '2019-10-24T19:51:40+00:00'
}
###########################
\tests\TestCase\I18n\TimeTest.php (line 81)
########## DEBUG ##########
'10/24/19, 4:51 PM'
###########################
\tests\TestCase\I18n\TimeTest.php (line 82)
########## DEBUG ##########
'10/24/19, 4:51 PM'
###########################
\tests\TestCase\I18n\TimeTest.php (line 83)
########## DEBUG ##########
'2019-10-24 16:51:40'
###########################
\tests\TestCase\I18n\TimeTest.php (line 84)
########## DEBUG ##########
'2019-10-24 16:51:40'
###########################
\tests\TestCase\I18n\TimeTest.php (line 85)
########## DEBUG ##########
[
(int) 0 => [
'ts' => (int) 1546308000,
'time' => '2019-01-01T02:00:00+0000',
'offset' => (int) -7200,
'isdst' => true,
'abbr' => '-02'
],
(int) 1 => [
'ts' => (int) 1550368800,
'time' => '2019-02-17T02:00:00+0000',
'offset' => (int) -10800,
'isdst' => false,
'abbr' => '-03'
],
(int) 2 => [
'ts' => (int) 1572750000,
'time' => '2019-11-03T03:00:00+0000',
'offset' => (int) -7200,
'isdst' => true,
'abbr' => '-02'
]
]
###########################
phpinfo()
date
date/time support => enabled
timelib version => 2017.09
"Olson" Timezone Database Version => 2018.9
Timezone Database => internal
Default timezone => America/Sao_Paulo
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment