View previous topic :: View next topic |
Author |
Message |
Mister Internet Smarty Rookie
Joined: 21 Apr 2003 Posts: 9
|
Posted: Mon Apr 21, 2003 7:31 pm Post subject: date_format |
|
|
Ok, am I the only one that this bugs out on? EVERY SINGLE other feature of Smarty I've tried has been flawless, but this one thing will not work. Maybe it's my configuration, that's why I'm posting... I'm running Smarty 2.5.0 on PHP 4.3.0 (web module).
I am using PEAR to get a row from a MySQL DB... the date that comes back is in the format "2002-10-10". However, when I try to display using the date_format variable modifier like so: {$Result.DATE|date_format:"%A, %B %e, %Y"}, I get this output on the page: "Monday, October , 2002".
Has anyone else seen this? Notice the extra space that's inserted between the month and the comma before the year, where the day number should be... not sure if it's a clue or not...
thanks all! |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Mon Apr 21, 2003 8:01 pm Post subject: |
|
|
So you're saying the date is wrong, or the formatting is wrong? The reason there is a space is because %e is rendering nothing for you. That means your strftime() function doesn't understand %e. Smarty just uses strftime() to format your date strings.
Code: |
%A, %B %e, %Y
Monday, October , 2003
^ ^ ^ ^
| | | |
| | | -> %Y
| | |
| | --> %e (nothing!)
| |
| --> %B
|
--> %A
|
Last edited by mohrt on Mon Apr 21, 2003 8:45 pm; edited 1 time in total |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Mon Apr 21, 2003 8:15 pm Post subject: |
|
|
that %e is empty sounds *really* strange to me also.
as a side note:
2002-10-10 was a thursday.
2003-10-10 will be a friday.
so no mondays here |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Mon Apr 21, 2003 8:27 pm Post subject: |
|
|
to investigate this further:
what operating system are you using?
does {"2002-10-10"|date_format} (without format-parameter) work and print
"Oct 10, 2002" ? or is the 10 there missing also?
maybe your locale-settings are broken.
overall it doesn't look like a smarty issue to me, but a php issue. but i may be wrong. |
|
Back to top |
|
Mister Internet Smarty Rookie
Joined: 21 Apr 2003 Posts: 9
|
Posted: Mon Apr 21, 2003 8:31 pm Post subject: |
|
|
Ok, you caught me. :
I was using 2002-10-10 as a formatting example... the two had no data integrity implied... sorry for not clearing that up ahead of time... I'm getting sloppy!
Anyway, I'm really concerned if this is a PHP-core level thing, because I'm running 4.3.0 and it's been very stable. I've got PEAR and other native PHP stuff running as well with no problems. If the pre-req for Smarty is PHP 4.0.6, then that should not be an issue.
Hmm.... maybe we just wait and see if any other developers have had a similar problem? My main issue is NOT data integrity... the main issue was the display, and the fact that it just seems to lose the day number when displaying. |
|
Back to top |
|
Mister Internet Smarty Rookie
Joined: 21 Apr 2003 Posts: 9
|
Posted: Mon Apr 21, 2003 8:31 pm Post subject: |
|
|
Just saw you last message... let me check... |
|
Back to top |
|
Mister Internet Smarty Rookie
Joined: 21 Apr 2003 Posts: 9
|
Posted: Mon Apr 21, 2003 8:34 pm Post subject: |
|
|
Well, it seems we've found the problem... none of the date formatting retains the day number... I will check all my locale settings and make sure they are kosher... will update when a solution is found... thanks! |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Mon Apr 21, 2003 8:36 pm Post subject: |
|
|
i knew it was not a data-integrity problem. i was just happy that there where no mondays |
|
Back to top |
|
Mister Internet Smarty Rookie
Joined: 21 Apr 2003 Posts: 9
|
Posted: Mon Apr 21, 2003 8:57 pm Post subject: |
|
|
Well, I've looked into it and I must admit I'm confused... I am just trying to get this to work with default locale settings, as I have not set my app up to store and use user-specified locale.... where would I start looking for this at the PHP level? |
|
Back to top |
|
alan Smarty Regular
Joined: 17 Apr 2003 Posts: 43
|
Posted: Mon Apr 21, 2003 9:00 pm Post subject: |
|
|
I think you need to look at the man pages for the 'c' function strftime(). It's generally a problem on Windows machines and has nothing to do with Smarty.
Best advice is to write your own date_format modifier. |
|
Back to top |
|
|