stripchars = $stripchars; } public function replace($pattern) { return preg_replace('/[' . $this->stripchars . ']/', '', $pattern); } } class StartEndTrim implements PatternModifier { private $skipstart; private $skipend; public function __construct($skipstart, $skipend) { $this->skipstart = $skipstart; $this->skipend = $skipend; } public function replace($pattern) { return substr($pattern, $this->skipstart, -$this->skipend); } } class Combined implements PatternModifier { private $modifiers; public function __construct($modifiers) { $this->modifiers = $modifiers; } public function replace($pattern) { $result = $pattern; foreach($this->modifiers as $m) { $result = $m->replace($result); } return $result; } } function mik_date($locale, $t, $format, $pattern_modifier = null) { $idf = new IntlDateFormatter($locale, $format, IntlDateFormatter::NONE); if($pattern_modifier != null) { $pattern = $idf->getPattern(); $pattern = $pattern_modifier->replace($pattern); $idf->setPattern($pattern); } return $idf->format($t); } $t = time(); echo mik_date('da_DK', $t, IntlDateFormatter::LONG) . "\r\n"; echo mik_date('en_US', $t, IntlDateFormatter::LONG) . "\r\n"; echo mik_date('da_DK', $t, IntlDateFormatter::LONG, new RegexRemove('y,')) . "\r\n"; echo mik_date('en_US', $t, IntlDateFormatter::LONG, new RegexRemove('y,')) . "\r\n"; echo mik_date('da_DK', $t, IntlDateFormatter::SHORT) . "\r\n"; echo mik_date('en_US', $t, IntlDateFormatter::SHORT) . "\r\n"; echo mik_date('da_DK', $t, IntlDateFormatter::SHORT, new Combined([new RegexRemove('y'), new StartEndTrim(0, 1)])) . "\r\n"; echo mik_date('en_US', $t, IntlDateFormatter::SHORT, new Combined([new RegexRemove('y'), new StartEndTrim(0, 1)])) . "\r\n"; ?>