<pubDate>Thu, 14 Feb 2013 13:15:00 +0100</pubDate>
<pubDate>czw, 14 lut 2013 13:15:00 +0100</pubDate>
<pubDate>[[+publishedon:strtotime:locale=`en_US`:date=`%a, %d %b %Y %H:%M:%S %z`]]</pubDate>
This question has been answered by gadamiak. See the first response.
you can't really set a locale for strtotime. If you're American, you see 11/12/10 and think "12 November, 2010". If you're Australian (or European), you think it's 11 December, 2010. If you're a sysadmin who reads in ISO, it looks like 10th December 2011.
The best way to compensate for this is by modifying your joining characters. Forward slash (/) signifies American M/D/Y formatting, a dash (-) signifies European D-M-Y and a period (.) signifies ISO Y.M.D.
Observe:
<?php
echo date("jS F, Y", strtotime("11.12.10"));
// outputs 10th December, 2011
echo date("jS F, Y", strtotime("11/12/10"));
// outputs 12th November, 2010
echo date("jS F, Y", strtotime("11-12-10"));
// outputs 11th December, 2010
?>
<?php setlocale(LC_TIME, 'en_US');
<?php
/*
* (Re)Sets locale
*
* Usage
* - [[locale? &category=`LC_TIME` &locale=`en_US`]]
* - [[...:locale=`category==LC_TIME||locale==en_US`:...]]
*
* When called without &locale will reset it to system setting
*
* Params:
* - category: a named constant specifying the category of the functions
* affected by the locale setting
* - locale: a locale to set, eg. "en_US"
*/
/* Initialize */
$category = $modx->getOption('category', $scriptProperties, 'LC_ALL');
$config = $modx->getConfig();
$locale = ($locale = $modx->getOption('locale', $scriptProperties, '')) ? $locale : $config['locale'];
unset($config);
/* If used as output filter */
if (isset($input)) {
$modx->getService('parser', 'modParser');
$options = $modx->parser->parseProperties($options);
$locale = (array_key_exists('locale', $options)) ? $options['locale'] : $locale;
$category = (array_key_exists('category', $options)) ? $options['category'] : $category;
unset($options);
}
return setlocale($category, $locale);
@BobRay: The question is not about the timestamp content but it's format. The problem is in names (not numbers!) used in the time format.
<?php
/*
* (Re)Sets locale
*
* Set locale for time to `en_US.utf8`:
*
* [[locale? &category=`LC_TIME` &locale=`en_US.utf8`]]
* [[...:locale=`category==LC_TIME||locale==en_US.utf8`:...]]
*
* Reset to system locale for all categories:
*
* [[locale]]
*
* Params:
* - category: a named constant specifying the category of the functions
* affected by the locale setting
* - locale: a locale to set, eg. "en_US.utf8"
*/
/* Initialize */
(string) $category = $modx->getOption('category', $scriptProperties, 'LC_ALL');
$config = $modx->getConfig();
(string) $locale = ($locale = $modx->getOption('locale', $scriptProperties, '')) ?
$locale : $syslocale = $config['locale'];
unset($config);
/* If used as output filter */
if (isset($input)) {
$modx->getService('parser', 'modParser');
$options = $modx->parser->parseProperties($options);
$locale = (array_key_exists('locale', $options)) ?
(string) $options['locale'] : $locale;
$category = (array_key_exists('category', $options)) ?
(string) strtoupper($options['category']) : $category;
unset($options);
}
setlocale($category, $locale);
if (isset($input))
return $input;
return;
<?php setlocale(LC_ALL, 'en_US'); return strftime($options,$input);
[[+publishedon:strtotime:dateLocale=`%a, %d %b %Y %H:%M:%S %z`]]