5281670

I posted the following to a Blogger developers’
discussion,
and thought it might be useful reposting it here as
search engine fodder.

Igor Mousse wrote:

Developers: BlogItemDateTime : date format

Could you add more option to the BlogItemDateTime tag?
Especially concerning the order of day and month. In
France, and in many other countries, we write a date
like that: day/month/year instead of month/day/year
like you do.

Thanks a lot. Blogger is great!

If you have SSI and Perl enabled on your machine, you
might want to try the following.  This solution has the
advantage of working on browsers that do not support
Javascript, as opposed to Mr. Ringnalda’s fine
solution.  These instructions presume an Apache server,
a UNIX-type OS, and a shell account (you will have to
adjust some instructions if this does not properly
reflect your system.)

  1. Configure Blogger (in ‘Settings’) to use the
    ‘Date/Time Format’ that looks like ‘8/16/2001 11:37:59
    AM’.  Set the ‘Date Header Format’ to look like
    ‘Thursday, August 16, 2001′.

  2. Copy the following (everything between, but not
    including, the ***s) into a text editor, save it as
    ‘reformatdate.pl’, and upload to your server.

    
    ****************
    #!/usr/bin/perl
    # Routine for reformatting Blogger dates.
    # Performs the following translations:
    #       8/16/2001 1:37:59 PM' ->
    #          '16 August 2001 13:37:59'
    #       Thursday, August 16, 2001' ->
    #          'Thursday, 16 August 2001'
    # Written by Joshua McGee ( http://www.mcgees.org |joshua@mcgees.org ) 
    
    die unless ($indate = shift);
    @months = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
    
    if (($m,$d,$y,$h,$mi,$s,$pm) =
     ($indate =~ m|^\s*(\d+)/(\d+)/(\d+) (\d+):(\d+):(\d+) (.)M$\s*|))
    {
            $h += 12 unless ($pm eq 'A');
            $m--;
            print "$d $months[$m] $y $h:$mi:$s\n";
    }
    elsif (($w,$m,$d,$y) =
     ($indate =~ m|^\s*(\w+), (\w+) (\d+), (\d+)\s*$|))
    {
            print "$w, $d $m $y\n";
    }
    ****************
    
  3. Change the script file permissions to be
    world-readable and -executable (type “chmod 755
    reformatdate.pl” in the scripts directory.)

  4. Everywhere you want <$BlogItemDateTime$>,
    use:

    <!--#exec
    cmd="/script_directory/reformatdate.pl
    '<$BlogItemDateTime$>'" -->

    Note that ‘/script_directory/’ is an absolute path
    on the machine itself, not relative to the
    HTML root.  That is, it will probably look something
    like ‘/home/users/foo/www/html/scripts/‘.  Type pwd
    in the scripts directory to get the correct
    path.

  5. For <$BlogDateHeaderDate$>, just replace
    <$BlogItemDateTime$> with
    <$BlogDateHeaderDate$> in step 4.

  6. That’s it.
Your ad here for US$1/month.  Find out how.


Leave a Reply, but read first

  1. Feel free to leave replies even to very old posts.
  2. You have pretty much free rein to write whatever you like.  Just make it contentful and it will probably stay, even if you are abusing me.  Just:
  3. Don't bother spamming.  Your links are automatically tagged "nofollow".  You won't increase your Google rating.  Nobody will click them anyway.  Save us both some time.
  4. Advertising Policy: The URL field is for personal blogs, not commercial enterprises.  Have a valid website or product to advertise?  Those do get clicked, and it's cheap.  Click here to advertise.  Otherwise, your URL is subject to deletion at editor's discretion.