Date formatting not working after installing qTranslate

I just installed qTranslate to have multilingual entries. It's a really good internationalization plugin, I've used it on other WordPress installations before with great results.

After installing it with WordPress 3.0.1 though, the date format for posts wasn't being parsed, showing instead the raw format:

Posted on %e de %B de %Y by johnny

I found a solution for this on the qTranslate forums:

  • Edit qtranslate_utils.php, line 143 from this:
    $date_parameters[] = '#%#'; $strftime_parameters[] = '%%';
    to this:
    $date_parameters[] = '#%#'; $strftime_parameters[] = '%';

It seems the extra percentage sign makes it so the percentage sign in the format gets interpreted as literal percentage signs and therefore they don't get parsed by strftime().

The formatting in Spanish and Catalan isn't completely fixed though, spurious "02UTC" strings are being added after each date component.


About johnny

Computers have interested me since I can remember and conveniently I studied computer science. I also enjoy performing in a local amateur theatre group and cycling. This is where I post solutions to problems I've had in the office or any other project, hopefully clearly enough to refer back to in the future.
This entry was posted in Uncategorized. Bookmark the permalink.

23 Responses to Date formatting not working after installing qTranslate

  1. mirick says:

    jotter more like.. blog?

  2. mirick says:

    it's a blog is what i'm saying

  3. mirick says:

    you have a blog.

  4. johnny says:

    is this blog?

  5. mirick says:

    it's your blog. you have one.

  6. Thor says:

    Thanks, That helped!

  7. etags says:

    Comenté las líneas144 a 146 y funciona bien para español. espero que sirva .Gracias

  8. etags says:

    De nuevo, tuve que corregir algunas líneas pero creo que de esta manera funciona bien, por cierto es un bug del qtranslate ya que reemplaza los strings donde encuentra los caracteres %d o "d" simplemente , asi que limite esos caracteres para que se pueda tomar los caracteres que se forman de esta forma "%d", " d ","d "," d"

    Estas son las líneas a cambiar en el archivo qtranslate_utils.php
    línea 143

    $date_parameters[] = '#%#'; $strftime_parameters[] = '%';
    foreach($mappings as $df => $sf) {
    //$a = '#(([^%\\\\])'.$df.'|^'.$df.')#';
    $a = "#([^%a-z ]".$df."| ".$df." |^".$df. "| ".$df."$)#";
    $b = ' ${2}'.$sf;
    $date_parameters[] = $a; $strftime_parameters[] = $b;


  9. Dude! Thanks so much for taking the trouble to document this: your proposed solution worked like a charm. My warm best wishes to you.

  10. Pingback: How to avoid dates look like ‘%A %B %e%q, %Y’ in Wordpress blogs? | Calmarius' website

  11. Merciiiiii he estado buscando esta solución mucho rato!!! Genial

  12. Gustavo says:

    Hola etags, por favor, necesito tu ayuda urgente. He hecho los cambios del codigo como has explicado y se me ha arruinado el archivo "qtranslate_utils.php". Me sale un aviso que dice: "Parse error: syntax error, unexpected '>' in C:\Inetpub\vhosts\\httpdocs\web\wp-content\plugins\qtranslate\qtranslate_utils.php on line 130" y no me deja hacer nada mas. Tuve la precausion de guardar en txt el codigo original; lo restauré pero sigue sin funcionar. Por favor dime que puedo hacer.

  13. Gustavo says:

    Lo he solucionado. No podia restaurarlo, supondo que porque al pegar el codigo en el Bloc de notas me habia desaparecido el formato y cambiaba el número de cada línea. Abrí el archivo con WordPad y copié desde ahí el codigo para despues pegarlo en el archivo del qTranslater.
    Igual te agradeceria si pudieras decirme en que he fallado para que no me funcione el cambio que tu propones.

  14. Pingback: wordpress plugin | Pearltrees

  15. Markus says:

    Hi and thanks a lot for publishing this bugfix for qtranslate!
    Worked fine for me. I am running wordpress version 3.3.1

    The only small difference was that you find the line of code in line 151 (qtranslate_utils.php)


  16. Ben Irvin says:

    For anyone who installs qTranslate in 2012 and has this problem, you no longer have to edit any files.

    All you have to do now is go to qTranslate language settings -> "Advanced Options" -> "Date / Time Conversion" -> "Use strftime instead of date and replace formats with the predefined formats for each language."

  17. Poster says:

    Thanks Ben Irvin!! :-)

  18. Rodrigo says:

    Hello. I just did what Ben Irvin says but i only got the time where the date was. Im using q translate i german, english and spanish. It translate the date for english and spanish but no german on my posts. Thanks for any idea. R

  19. krembo99 says:

    No need to Change the code , in 99% of the cases , what is needed is to choose the "Use strftime instead of date and replace formats with the predefined formats for each language.
    Depending on the mode selected, additional customizations of the theme may be needed" option in Advanced Settings in Qtranslate options ..

  20. JonK says:

    Amazing solution, this works for me.

    etags tu solución es genial, tenía un problema de formateo y ahora me lo has solucionado.

  21. Pingback: Wordpress qTranslate plugin date problem | Leo Panigo

  22. Lenin says:

    Ben Irvin and Krembo99 deserves a clap. You do not need to alter the code.

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>