Support » Requests and Feedback » Localised time format (strftime) for posts

  • I’d like to be able to use the (localised) strftime formatting for the titles of the blogs. That would allow titles like: Monday, December 23rd.

    In fact i did it myself on my blog. The only thing to do is to modify the functions mysqltodate in “functions.php” and the_date in “template-functions-general.php” by adding a supplementary boolean argument, say “use_local”.

    Once these functions are modified you just have to put something like the_date(‘%A %e %B %G’,'<h2>’,'</h2>’, 1, 1); for the title of each post.

    Can this feature be added in wordpress?

    Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • chtito, ever thought of sticking your changes into a plugin?

    Yes, you’re right!! Here is the plugin (it’s too simple to be made a general purpose plugin, imo). I didn’t use the strftime function because the right locale is very difficult to get. It requires to have the date in the ISO format, like 2005-01-13. So here is the code:

    function frenchMonth($n)

    $months = array("janvier", "février",
    "mars", "avril", "mai", "juin", "juillet", "août",
    "septembre", "octobre", "novembre","décembre");
    return $months[$n-1];

    function frenchWeekday($d)
    $days = array("Dimanche", "Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi");
    return $days[$d];

    function localTimeFilter($theDate)
    if (empty($theDate))
    return $theDate;
    $date = explode("-",$theDate);
    $phptime = mktime(0,0,0,$date[1], $date[2], $date[0]);

    return "<h2>".frenchWeekday(date("w", $phptime))." ".date("j", $phptime)." ".frenchMonth(date("n", $phptime))." ".date("Y", $phptime)."</h2>";
    //return "<h2>".strftime("%A %e %B %G", $phptime)."</h2>";

    add_filter("the_date", "localTimeFilter");


Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Localised time format (strftime) for posts’ is closed to new replies.