A little problem with date_helper |
[eluser]Unknown[/eluser]
I'm starting with CI and I was looking for a way to display the name of month. I've discovered the date_helper and when looking into http://ellislab.com/codeigniter/user-gui...elper.html I found the mdate(). It says that Quote:This function is identical to PHPs date() function, except that it lets you use MySQL style date codes, where each code letter is preceded with a percent sign: %Y %m %d etc. But I tryed to get the month name and I got caught in this line of the mdate() method. Code: $datestr = str_replace('%\\', '', preg_replace("/([a-z]+?){1}/i", "\\\\\\1", $datestr)); The problem is that for date('F') I got February for mdate('F') I got F. I don't know how much I can change this str_replace and maintain it working for all the other functions (that I probably haven't figured yet). I'm noobie to regular expressions as well... In second place I have to translate the name of the month to Portuguese. Thanks for reading and thinking about it...
[eluser]moodsey211[/eluser]
The function date and mdate have different formats in its parameters. If date('F') gives you the full name of the current month, in mdate, you should have something like this: mdate('%M')
[eluser]Unknown[/eluser]
Thank you, it was almost exactly what I needed. I had used a similar approach ( little bit lammer ) If possible could you tell me where did you get the acceptables formats to use into mdate()? something such as %M = part of months name %d = number of current day and so on? Follows the modification I did to the mdate() Code: function mdate($datestr = '', $time = '') Code: function periodo_mes($tipo = ''){ extenso = full name mes = month periodo = period (not the red one) |
Welcome Guest, Not a member yet? Register Sign In |