carlfaulkner Posted May 29, 2012 Share Posted May 29, 2012 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 More sharing options...
thescientist Posted May 29, 2012 Share Posted May 29, 2012 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 More sharing options...
niche Posted May 29, 2012 Share Posted May 29, 2012 (edited) 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 May 29, 2012 by niche Link to comment Share on other sites More sharing options...
Guest So Called Posted May 29, 2012 Share Posted May 29, 2012 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now