Page 1 of 1

Changing the format of entry dates in English

Posted: Fri Sep 27, 2013 12:55 pm
by Carl @ ATS
Hi,

Whenever I publish new entries for my English blog, the date of the entry that appears above them gets written this way:

FRIDAY, SEPTEMBER 20. 2013

Can anyone tell me how to get Serendipity to write "Friday, 20 September 2013" instead, please?
In other words, using:
- normal spelling with a mixture of upper- and lower-case spelling, not just upper- or lower-case
- British-style dates rather than American (i.e. with the date before the month)
- no full stop before the year (which, incidentally, is wrong in English anyway; it ought to be a comma for American English).

I realise upper and lower case are part of CSS, but the format I want is a mixture of both; how do you get that? I also realise that entry dates are created using variables, but I'm not a programmer and don't know how to adapt the programming. :shock: Is there a (relatively simple) way of adapting the date format, and which file does this bit of code need to be inserted in?

The template I'm currently using for the blog is "Competition" and I'm using the latest build, 1.7.3.

I'd appreciate any ideas. The lower-case issue isn't very important, really, but I would like to use a British date format if possible.

Regards

Carl

My blog's here: www.ampertrans.de/blog/

Re: Changing the format of entry dates in English

Posted: Fri Sep 27, 2013 1:25 pm
by garvinhicking
Hi!

There are multiple ways to deal with this:

1. Edit lang/(UTF-8)/serendipity_lang_XX.inc.php for the language that your blog's runnin in (i.e. "en" or "de", or whatever). Change the constant:

Code: Select all

@define('DATE_FORMAT_ENTRY', '%A, %B %e. %Y');
to:

Code: Select all

@define('DATE_FORMAT_ENTRY', '%A, %e %B %Y');
2. Edit your custom template files (usually only entries.tpl) that refer to DATE_FORMAT_ENTRY and replace it with a string that you want your formatting to appear as. I.e. change:

Code: Select all

{$dategroup.date|@formatTime:DATE_FORMAT_ENTRY}
to:

Code: Select all

{$dategroup.date|@formatTime:"%A, %e %B %Y'"}
HTH,
Garvin

Re: Changing the format of entry dates in English

Posted: Fri Sep 27, 2013 2:04 pm
by Carl @ ATS
Thanks very much, Garvin. That was very helpful. :D

The only thing I've altered in your snippet of code is the apostrophe after the year, which I got rid of, leaving this: {$dategroup.date|@formatTime:"%A, %e %B %Y"}. I edited entries.tpl in my template folder.

Thanks again - that's my main issue sorted out. (I'll just skip the lower-case one, I think.)

Best,

Carl

Re: Changing the format of entry dates in English

Posted: Sat Sep 28, 2013 1:51 pm
by yellowled
Carl @ ATS wrote:(I'll just skip the lower-case one, I think.)
In your style.css, find

Code: Select all

.serendipity_date {
    font-family: Arial, Geneva, Helvetica, sans-serif;
    font-size: x-small;
    color: #607080;
    text-transform: uppercase;
    letter-spacing: 1px;
    width: 95%;
    padding-bottom: 10px;
    margin-left: auto;
    margin-right: auto;
    margin-top: 3px;
    text-align: left;
}
and remove only this line

Code: Select all

text-transform: uppercase;
YL

Re: Changing the format of entry dates in English

Posted: Sat Sep 28, 2013 1:53 pm
by yellowled
Also, since competition is part of the s9y core, be advised that your changes in entries.tpl and style.css (basically, in any file which is part of competition) will be overwritten. You might want to move your edited copy to a seperate template directory and use this “forked” templates.

YL

Re: Changing the format of entry dates in English

Posted: Fri Oct 04, 2013 10:28 am
by Carl @ ATS
Morning YellowLed,

Thanks for giving me these two additional tips, which are very useful.

I've already noticed that s9y doesn't want me to change anything in the files as "error" messages now appear whenever I try and verify the installation - due to the modifications I've made in the core files, as you say. This is a bit annoying since the errors aren't mistakes or unexpected file corruptions - it would be nicer (= more reassuring) to get a "clean" report, as it were, but how do I get that, I wonder? If I moved the files I've changed "elsewhere" (where exactly?) and left the original files untouched, that would presumably work, but what references in files (i.e. paths) need to be changed for s9y to find the edited files and display my blog the way I want it to? Any ideas?

Regards

Carl

www.ampertrans.de/blog/ (s9y 1.7.3)

Re: Changing the format of entry dates in English

Posted: Mon Oct 07, 2013 10:22 am
by Timbalu
Just to answer this:
The Serendipity Integrity Check, checks whether files are corruped, changed or touched, and, in any case, responds "file-xy corrupt or modified: failed verification".
This works for all released (zipped) files via checksums. Changing core files in general is not recommended, if not really in need.

Now, if you really need to change something in the core, better note it somewhere, to remember this for yourself. The checksum check does not know whether the changing person pursued good or bad intentions. If the change is an enhancement, discuss with us here, to change for us all.

If you need to change any files in a core delivered template, like Garvin suggested for the lang above, copy the template in the template folder, rename the directory and edit the info.txt, to hold that new name. Now you can easily switch to that theme in backends "Change Style" and edit it in various ways without the checksum validator noticing. In your case: templates/competition.

Re: Changing the format of entry dates in English

Posted: Mon Oct 07, 2013 10:59 am
by Carl @ ATS
Thanks for the explanation, Ian.

Regards

Carl

Re: Changing the format of entry dates in English

Posted: Mon Jan 27, 2014 4:10 pm
by Carl @ ATS
Hi everyone,

I'm currently trying out some of the alternative templates s9y provides and would like to use "Bulletproof" for a while as I like the clear layout. :D Can anyone advise me how to change the current date format, please? The date of my last blog post is "Friday, January 24. 2014", for example, whereas I'd like it to be "Friday, 24 January 2014".

I encountered the same issue last year with "Competition", but was able to adjust the date using Garvin's tips (see above). For some reason, these don't seem to work for "Bulletproof", though - none of the changes has had any effect. :shock:

It looks as though I could set the date format from s9y's control panel under "Appearance" > "Manage styles", but if I click on the drop-down in the row called "Dateformatting", the British English format I want (%A, %e %B %Y) doesn't seem to be listed (see the attached screen shot). Can I set the date format anywhere else, I wonder?

Regards,

Carl

P.S. As an aside, if you look at the first entry, you'll see the current setting, which contains a mistake - a full stop appears before the year instead of a comma. Would someone correct that, please?

Re: Changing the format of entry dates in English

Posted: Tue Jan 28, 2014 7:58 pm
by Don Chambers
You can add that option to the list of available date format choices. In your template folder, edit the file config.inc.php using a simple text editor. At approximately line 130, you will find the date formatting options defined as follows:

Code: Select all

    array(
        'var'           => 'date_format',
        'name'          => GENERAL_PLUGIN_DATEFORMAT . " (http://php.net/strftime)",
        'type'          => 'select',
        'default'       => DATE_FORMAT_ENTRY,
        'select_values' => array(DATE_FORMAT_ENTRY => DATE_FORMAT_ENTRY,
                                 '%a, %e. %B %Y' => '%a, %e. %B %Y',
                                 '%d-%m-%y' => '%d-%m-%y',
                                 '%m-%d-%y' => '%m-%d-%y',
                                 '%a %d-%m-%y' => '%a %d-%m-%y',
                                 '%a %m-%d-%y' => '%a %m-%d-%y',
                                 '%b %d' => '%b %d',
                                 "%b %d '%y" => "%b %d '%y")
    ),
Simply add yours to that list as follows:

Code: Select all

    array(
        'var'           => 'date_format',
        'name'          => GENERAL_PLUGIN_DATEFORMAT . " (http://php.net/strftime)",
        'type'          => 'select',
        'default'       => DATE_FORMAT_ENTRY,
        'select_values' => array(DATE_FORMAT_ENTRY => DATE_FORMAT_ENTRY,
                                 '%a, %e. %B %Y' => '%a, %e. %B %Y',
                                 '%d-%m-%y' => '%d-%m-%y',
                                 '%m-%d-%y' => '%m-%d-%y',
                                 '%a %d-%m-%y' => '%a %d-%m-%y',
                                 '%a %m-%d-%y' => '%a %m-%d-%y',
                                 '%b %d' => '%b %d',
                                 "%b %d '%y" => "%b %d '%y",
                                 "%A, %e %B %Y" =>"%A, %e %B %Y")
    ),
You will need to repeat this modification for future s9y upgrades unless you have copied the bulletproof files to your own unique template folder.