Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

date_format

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Bugs
View previous topic :: View next topic  
Author Message
Mister Internet
Smarty Rookie


Joined: 21 Apr 2003
Posts: 9

PostPosted: Mon Apr 21, 2003 7:31 pm    Post subject: date_format Reply with quote

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
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Mon Apr 21, 2003 8:01 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Mon Apr 21, 2003 8:15 pm    Post subject: Reply with quote

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 Smile
Back to top
View user's profile Send private message Send e-mail Visit poster's website
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Mon Apr 21, 2003 8:27 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
Mister Internet
Smarty Rookie


Joined: 21 Apr 2003
Posts: 9

PostPosted: Mon Apr 21, 2003 8:31 pm    Post subject: Reply with quote

Ok, you caught me. : Laughing

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! Smile

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
View user's profile Send private message
Mister Internet
Smarty Rookie


Joined: 21 Apr 2003
Posts: 9

PostPosted: Mon Apr 21, 2003 8:31 pm    Post subject: Reply with quote

Just saw you last message... let me check...
Back to top
View user's profile Send private message
Mister Internet
Smarty Rookie


Joined: 21 Apr 2003
Posts: 9

PostPosted: Mon Apr 21, 2003 8:34 pm    Post subject: Reply with quote

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
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Mon Apr 21, 2003 8:36 pm    Post subject: Reply with quote

i knew it was not a data-integrity problem. i was just happy that there where no mondays Wink
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Mister Internet
Smarty Rookie


Joined: 21 Apr 2003
Posts: 9

PostPosted: Mon Apr 21, 2003 8:57 pm    Post subject: Reply with quote

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
View user's profile Send private message
alan
Smarty Regular


Joined: 17 Apr 2003
Posts: 43

PostPosted: Mon Apr 21, 2003 9:00 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Bugs All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP