Skip to content

Instantly share code, notes, and snippets.

@Spriz
Last active August 20, 2019 12:54
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 Spriz/d396e30451ab263b98c2e3b92dffaedd to your computer and use it in GitHub Desktop.
Save Spriz/d396e30451ab263b98c2e3b92dffaedd to your computer and use it in GitHub Desktop.
<?php
use Cake\I18n\Date;
use Cake\I18n\FrozenDate;
use Cake\I18n\FrozenTime;
use Cake\I18n\Time;
// Default config stuff
/*
* Set default date & time for both mutable and immutable values
*/
$dateTimeToStringFormat = [
IntlDateFormatter::MEDIUM,
IntlDateFormatter::SHORT,
];
$dateToStringFormat = [
IntlDateFormatter::SHORT,
IntlDateFormatter::NONE,
];
$locale = 'nl-NL';
FrozenTime::setDefaultLocale($locale);
Time::setDefaultLocale($locale);
FrozenDate::setDefaultLocale($locale);
Date::setDefaultLocale($locale);
FrozenTime::setToStringFormat($dateTimeToStringFormat);
Time::setToStringFormat($dateTimeToStringFormat);
FrozenDate::setToStringFormat($dateToStringFormat);
Date::setToStringFormat($dateToStringFormat);
FrozenTime::$niceFormat = $dateTimeToStringFormat;
Time::$niceFormat = $dateTimeToStringFormat;
FrozenDate::$niceFormat = $dateToStringFormat;
Date::$niceFormat = $dateToStringFormat;
<?php
use Cake\I18n\Time;
$troubledTimeInstance = new Time();
debug($troubledTimeInstance);
debug(\Cake\I18n\Time::getDefaultLocale());
debug(\Cake\I18n\I18n::getLocale());
debug(\Cake\I18n\I18n::getDefaultLocale());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment