You are not logged in.
- Topics: Active | Unanswered
#1 2008-06-19 22:05:18
- fpouget
- Member
- Registered: 2008-05-25
- Posts: 6
replace date by strftime in format_time function
Is not any plan to use strftime in order to allow the locale settings ?
Many did it 'by hand' with the 1.2.x ...
Offline
#2 2008-06-19 22:22:10
- elbekko
- Former Developer

- From: Leuven, Belgium
- Registered: 2008-04-30
- Posts: 1,131
- Website
Re: replace date by strftime in format_time function
Which only works if that locale exists on the server.
Ben
SVN repository for my extensions - The thread
Quickmarks 0.5
“Question: How does a large software project get to be one year late? Answer: One day at a time!” - Fred Brooks
Offline
#3 2008-06-19 22:54:09
- Smartys
- Former Developer
- Registered: 2008-04-27
- Posts: 3,135
- Website
Re: replace date by strftime in format_time function
I'm willing to look into making the change, but we need a robust way to come up with the locale. Otherwise, we can set it up properly for one group of people only to have another with issues. If anyone has a solution for it, I'm all ears.
Offline
#4 2008-06-20 06:34:20
- Jérémie
- Member

- From: Paris, France
- Registered: 2008-04-30
- Posts: 627
- Website
Re: replace date by strftime in format_time function
- checking if the proper locale is properly set, and then each time this is called :
if LocaleIsSet
strftime()
else
date()
Nope?
Offline
#5 2008-06-20 07:21:25
- Felix
- Member
- Registered: 2008-05-13
- Posts: 352
Re: replace date by strftime in format_time function
Easiest way is in my opinion this... Tho it isn't the best way for readability.
<?php
$function = 'date';
$format = 'd.m.Y';
echo $function($format);
?>Values could be filled by the Forum Config.
Offline
#6 2008-06-20 12:09:27
- Smartys
- Former Developer
- Registered: 2008-04-27
- Posts: 3,135
- Website
Re: replace date by strftime in format_time function
Jérémie and Felix: The issue isn't calling the setlocale function versus the date function, the issue is ensuring a uniform experience for people no matter what OS they're using.
It would be easy enough to allow the locale to be set in the language files. However, the value changes depending upon what OS is being used.
// Determine what locale to use
switch (PHP_OS)
{
case 'WINNT':
case 'WIN32':
$locale = 'english';
break;
case 'FreeBSD':
case 'NetBSD':
case 'OpenBSD':
$locale = 'en_US.US-ASCII';
break;
default:
$locale = 'en_US';
break;
}
// Attempt to set the locale
setlocale(LC_CTYPE, $locale);This is commented out code from 1.2's lang/English/common.php: would something similar allow for the locale to be set properly in most cases?
Offline
#7 2008-06-27 14:58:37
- Smartys
- Former Developer
- Registered: 2008-04-27
- Posts: 3,135
- Website
Re: replace date by strftime in format_time function
Anyone? ![]()
Offline
#8 2008-06-28 01:08:45
- Jérémie
- Member

- From: Paris, France
- Registered: 2008-04-30
- Posts: 627
- Website
Re: replace date by strftime in format_time function
I don't have the appropriate experience to list you the appropriate locales for most common set up.
I remember seeing this being an issue, and later being fine tuned, with Textpattern, but this was a while back (like 3 or 4 years). I also remember having to fiddle with it on one of my install, because it's slightly more tricky with utf8 (there's a bunch of different locales).
So it might take some serious real life testing, but ultimately yup it should work.
Offline
#9 2008-06-29 20:46:34
- Smartys
- Former Developer
- Registered: 2008-04-27
- Posts: 3,135
- Website
Re: replace date by strftime in format_time function
Thanks, I'll look into it. ![]()
Offline
#10 2008-07-17 23:43:45
- Smartys
- Former Developer
- Registered: 2008-04-27
- Posts: 3,135
- Website
Re: replace date by strftime in format_time function
And I'm finding myself very disappointed by the poor documentation of the strftime function compared to the date function, as well as by the fact that the specifiers depend entirely on the underlying OS. I've found several that refuse to work on my Windows computer, for example.
Offline
#11 2008-07-18 00:18:12
- Smartys
- Former Developer
- Registered: 2008-04-27
- Posts: 3,135
- Website
Re: replace date by strftime in format_time function
And I'm afraid I'm not going to be able to implement this in the core due to those issues. The date/gmdate functions are simply much, much better.
It is possible for someone to overwrite the format_time function using the extension system and implement this if they want it.
Offline
