Jump to content

convert timestamp month into french


carlfaulkner

Recommended Posts

Basically i am using timestamp in mysql and i am using the following php in my SELECT query DATE_FORMAT(timeStamp,'%d% %b %Y') This works. But i want to take say the month %b and basically convert the english month to french month if (month = "january") { $newmonth = "french name for janary"} how do i retrieve the month name or value to convert it and then still echo %d%, %b(but as converted month), %Y.

Link to comment
Share on other sites

You would probably have to create your own mapping to do that, i.e.

$month = 'january';$frenchMonthMapper = array(  'january' => 'janvier',  'february' => 'fevrier',  ...  'december' => 'decembre'); echo $frenchMonthMapper[$month];

Link to comment
Share on other sites

I like that scientist, but what putting that array in a table and doing a join? EDIT: That way it can all be done in sql.

Edited by niche
Link to comment
Share on other sites

Guest So Called

This is probably a dumb question since I don't use the codes referred to in the OP.... but why not use %c instead of %b? That makes month 0-12. (I understand the 0 value is because you can store incomplete dates such as 2014-00-00.) Then $monthFrench = array('zero month', 'janvier', 'fevrier', ..., 'decembre'); and finally, echo $monthFrench[$month]; Also read this: http://dev.mysql.com/doc/refman/5.5/en/locale-support.html You might be able to get your values directly in French.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...