help needed with setlocale and strftime question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sofasurfer
Forum Newbie
Posts: 3
Joined: Mon Jun 20, 2005 3:42 pm
Location: porto

help needed with setlocale and strftime question

Post by sofasurfer »

hello!

1st of all, let me thank everyone for helping me out.


my question:

my MySQL database has a datefield, that I need to output on the format Month Year (in Portuguese, for instance, May 2005).

my code



PHP:

Code: Select all

setlocale(LC_ALL, 'pt_PT.ISO8859-1', 'pt_PT.utf-8', 'portuguese', 'pt_PT');
and on the echo statement:

PHP:

Code: Select all

echo strftime($row_rsListaProvas['date_m']); ?><?php echo strftime($row_rsListaProvas['date_y']);

of course, date_m and date_y are alias fields that I create with the query to the database.

I get the result of the query in English...
how can I output it in Portuguese? the
echo strftime($row_rsListaProvas['date_m']);
outputs in english, even with the setlocale ok >> I tested the output of echo strftime('%B'); and outputed ok in Pt.

What I'm I doing wrong?

remeber, when I make the query, the results come on English.. is there a way for me to, besides altering the format of the datefield, to change also the language through the query?

or is there another way, a php way to output for instance Maio 2005 instead of May 2005?

the part of the query that needs :( help:

DATE_FORMAT( 'data' , '%%M' ) AS date_m

What can I do? :(

thx :)
method_man
Forum Contributor
Posts: 257
Joined: Sat Mar 19, 2005 1:38 am

Post by method_man »

DO NOT CROSS POST!!!
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

You could select the date as a UNIX_TIMESTAMP...
Post Reply