wordpress and the unix date format « bruno de florence

bdf

Bruno de Florence – artiste français installé à londres – pianiste improvisateur – diplômé de musicologie de Goldsmiths College Londres – co-curateur de Lutecium – également photographe – skally et puis bien d’autres encore – à suivre
wordpress and the unix date format
4 mars 2010 - catégories: WordPress - mots-clef: ,
i encountered an interesting fluke in converting Lutecium, a site of which i am co-curator, from HTML to WordPress 2.91.  A psychoanalytical archive, the site has in excess of 1500 documents, some of them dating back to 1926. From our users point of view,  it made sense to have the publishing date of each article set to that of the original publishing date of the document.  So far so good, and the site owner, Jacques Siboni, ran a quick script on a CSV file of the content which was then imported into WordPress db.

Then something strange started to happen. Some of the articles would be displayed with their correct date, and therefore in the correct order. But some of them would be displayed with today’s date, and therefore in the wrong order. We scratched our heads, examined the theme files, checked the forums, but to no avail.

Then Jacques, a bit of a Linux geek, noticed that the files exhibiting a date disorder had dates prior to 1970. Bingo, it had to do with the Unix file date format, which counts the number of milliseconds elapsed since 1st January 1970. Stupid but true. This returns a positive integer, which is then decoded to the DDMMYYY format. Therefore, any DDMMYYYY date prior to 1970 converted to the Unix format will become a negative integer.

Still, that did not explain everything. Why would WordPress convert a negative integer to today’s date? That’s because since version 2.8, the_date() function checks if the Unix integer is negative, and if it is, it returns today’s date. It’s all explained on the WordPress Trac site.

So if in your db you have articles dated prior to 1970, then in /wp-includes/functions.php uncomment lines 89-98. You will then obtain the proper date of your articles.

Well done us!

diffuser cet article
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • blogmarks
  • E-mail this story to a friend!
  • MySpace
  • Technorati
  • Twitter
  • Yahoo! Bookmarks
  • Yahoo! Buzz

articles similaires

lâche moi les baskets

depuis WP 2.7, une fonction qui permet d’afficher certains articles dit sticky en haut de page a été intégrée. pratique, sauf que les query retournent toujours les articles demandés avec…

colonnes à la une

un bricolage pour afficher les articles en colonnes.  la plupart des maquettes de WordPress affichent les articles sur une seule colonne.  il existe des solutions permettant de les afficher sur…

ce site

ce site tourne avec WordPress – un logiciel de gestion de contenu également dit blog – ce type de logiciel permet de n’avoir pas à se soucier du côté technique…



les commentaires sont fermés.