Dateformat

General questions about CMSimple
cmb
Posts: 12437
Joined: Tue Jun 21, 2011 11:04 am
Location: Mü-Sa, RLP, DE
Contact:

Re: Dateformat

Post by cmb » Thu Jan 11, 2018 12:01 am

lillebitte wrote:
Wed Jan 10, 2018 11:02 pm
Actually I have used 1/1-18, but that's no big deal, and 01.01.2018 or 01-01-2018 is more common, especially now a days.
Thanks! Could you please give these examples for January, 15th? (I just want to be sure whether it is day-month or month-day.)
lillebitte wrote:So now I'm just curious, what is Settings → Language → Lastupdate → Dateformat used for?
For a plain (i.e. unmodified) CMSimple_XH 1.7(.0 to .2) one has to distinguish whether the Intl extension is available or not:
  • Int extension is available:
    Settings → Configuration → Format → Date: a coarse declaration of the desired verbosity of the date format.
    Settings → Configuration → Format → Time: a coarse declaration of the desired verbosity of the time format.
    Settings → Language → Locale → All: the desired locale (for instance, en_US, da_DK or de_DE).
  • Intl extension is not available (identical to former behavior):
    Settings → Language → Lastupdate → Dateformat: a date()-style format.
These settings are used by XH_formatDate(), which again is used by lastupdate() and such.
Christoph M. Becker –Plugins for CMSimple_XH, but not for CMSimple 4+

lillebitte
Posts: 49
Joined: Fri Jan 29, 2016 7:20 am

Re: Dateformat

Post by lillebitte » Thu Jan 11, 2018 9:01 am

cmb wrote:
Thu Jan 11, 2018 12:01 am
... Could you please give these examples for January, 15th?...
That would be 15/1-18 (j/n-y).
A good thing about this format is that it is not used in English notation, so you can always be sure that it is day/month-year. When you use day-month-year you can not be sure if it has to be read as day-month-year, month-day-year - or even year-month-day in some cases and all three representations are with two digits.
cmb wrote:
Thu Jan 11, 2018 12:01 am
For a plain (i.e. unmodified) CMSimple_XH 1.7(.0 to .2) one has to distinguish whether the Intl extension is available or not:
  • Int extension is available:
    Settings → Configuration → Format → Date: a coarse declaration of the desired verbosity of the date format.
    Settings → Configuration → Format → Time: a coarse declaration of the desired verbosity of the time format.
    Settings → Language → Locale → All: the desired locale (for instance, en_US, da_DK or de_DE).
  • Intl extension is not available (identical to former behavior):
    Settings → Language → Lastupdate → Dateformat: a date()-style format.
These settings are used by XH_formatDate(), which again is used by lastupdate() and such.
I still do not understand, to me it seems that the date setting in Settings → Language is not used together php-intl. At least it doesn't affect my installation no matter how I define the dateformat.
I do not know much about php, I understand what lastupdate() is used for, but not XH_formatDate().

cmb
Posts: 12437
Joined: Tue Jun 21, 2011 11:04 am
Location: Mü-Sa, RLP, DE
Contact:

Re: Dateformat

Post by cmb » Thu Jan 11, 2018 1:17 pm

lillebitte wrote:
Thu Jan 11, 2018 9:01 am
cmb wrote:
Thu Jan 11, 2018 12:01 am
... Could you please give these examples for January, 15th?...
That would be 15/1-18 (j/n-y).
Thanks!
lillebitte wrote:I still do not understand, to me it seems that the date setting in Settings → Language is not used together php-intl. At least it doesn't affect my installation no matter how I define the dateformat.
Indeed, if php-intl is available, Settings → Language → Lastupdate → Dateformat is ignored.
lillebitte wrote:I do not know much about php, I understand what lastupdate() is used for, but not XH_formatDate().
XH_formatDate() is used by lastupdate() (and some other functions/plugins) to actually format the date/time.
Christoph M. Becker –Plugins for CMSimple_XH, but not for CMSimple 4+

lillebitte
Posts: 49
Joined: Fri Jan 29, 2016 7:20 am

Re: Dateformat

Post by lillebitte » Thu Jan 11, 2018 2:12 pm

cmb wrote:
Thu Jan 11, 2018 1:17 pm
Indeed, if php-intl is available, Settings → Language → Lastupdate → Dateformat is ignored.
Thanks. It might be an idea to provide this information in the settings page...?
cmb wrote: XH_formatDate() is used by lastupdate() (and some other functions/plugins) to actually format the date/time.
I see, thanks.

cmb
Posts: 12437
Joined: Tue Jun 21, 2011 11:04 am
Location: Mü-Sa, RLP, DE
Contact:

Re: Dateformat

Post by cmb » Sun Jan 14, 2018 4:06 pm

lillebitte wrote:
Thu Jan 11, 2018 2:12 pm
cmb wrote:
Thu Jan 11, 2018 1:17 pm
Indeed, if php-intl is available, Settings → Language → Lastupdate → Dateformat is ignored.
Thanks. It might be an idea to provide this information in the settings page...?
Well, the language settings do not allow any help texts, and the help text for Settings → Configuration → Format → Date already says:
The date format if ext/intl is available; otherwise the date/time format falls back to $tx['lastupdate']['format'].
Anyhow, I've now added some relevant documentation in the Wiki.
Christoph M. Becker –Plugins for CMSimple_XH, but not for CMSimple 4+

Tata
Posts: 2655
Joined: Tue May 20, 2008 5:34 am
Location: Slovakia
Contact:

Re: Dateformat

Post by Tata » Tue Jan 30, 2018 10:32 pm

It is really a little complicated to have the date/time format properly set conforming national specifics with v1.7.2.
Only now I see that the lastupdate on my webpage has English format.
template

Code: Select all

<?php $tx['lastupdate']['dateformat']="d.m.Y";echo lastupdate(1);?>
or

Code: Select all

<?php echo lastupdate(1);?>
returns
January 30, 2018 at 10:42 PM
This worked and still works fine with v1.6.10.
CMSimple.sk
It's no shame to ask for an answer if all efforts failed.
But it's awful to ask without any effort to find the answer yourself.

cmb
Posts: 12437
Joined: Tue Jun 21, 2011 11:04 am
Location: Mü-Sa, RLP, DE
Contact:

Re: Dateformat

Post by cmb » Tue Jan 30, 2018 11:07 pm

Tata wrote:
Tue Jan 30, 2018 10:32 pm
It is really a little complicated to have the date/time format properly set conforming national specifics with v1.7.2.
[…]

Code: Select all

<?php $tx['lastupdate']['dateformat']="d.m.Y";echo lastupdate(1);?>
What does "d.m.Y" mean? How can I get rid of the leading zeroes? – Ah, I have to use "j.n.Y", of couse! Or should it be "j.n.y"? Looks complicated to me; besides, I can't have localized month names.

As of CMSimple_XH 1.7.0, if the Intl extension is available (for details see the respective Wiki section), you just have to go to Settings → Language → Locale → All and choose the appropriate locale (if not already done) – in your case it would be sk_SK. Then you get something like "30. januára 2018, 0:14". If you don't like that you can go to Settings → Configuration → Format, and choose the desired format from a select list; e.g. Date=medium and Time=none would give "30. 1. 2018" – I'd prefer the default settings, though.
Christoph M. Becker –Plugins for CMSimple_XH, but not for CMSimple 4+

Tata
Posts: 2655
Joined: Tue May 20, 2008 5:34 am
Location: Slovakia
Contact:

Re: Dateformat

Post by Tata » Tue Jan 30, 2018 11:40 pm

Exactly so is everything adjusted:
config.php

Code: Select all

$cf['format']['date']="medium";
$cf['format']['time']="short";
sk.php

Code: Select all

$tx['locale']['all']="LC_ALL | sk_SK";
...
$tx['lastupdate']['dateformat']="d.m.Y H:i:s";
Result:
Jan 30, 2018, 10:42 PM
CMSimple.sk
It's no shame to ask for an answer if all efforts failed.
But it's awful to ask without any effort to find the answer yourself.

cmb
Posts: 12437
Joined: Tue Jun 21, 2011 11:04 am
Location: Mü-Sa, RLP, DE
Contact:

Re: Dateformat

Post by cmb » Wed Jan 31, 2018 12:25 am

Tata wrote:
Tue Jan 30, 2018 11:40 pm
sk.php

Code: Select all

$tx['locale']['all']="LC_ALL | sk_SK";
That appears to be wrong (don't know where the `LC_ALL` is coming from). It should rather be:

Code: Select all

$tx['locale']['all']="sk_SK";
PS: instead of `sk_SK` even `sk` seems to suffice!
Last edited by cmb on Wed Jan 31, 2018 12:30 am, edited 1 time in total.
Reason: added PS
Christoph M. Becker –Plugins for CMSimple_XH, but not for CMSimple 4+

Tata
Posts: 2655
Joined: Tue May 20, 2008 5:34 am
Location: Slovakia
Contact:

Re: Dateformat

Post by Tata » Wed Jan 31, 2018 8:05 am

Yes, that OK.
BTW, the previous code I have found here: http://php.net/manual/en/function.setlocale.php.
CMSimple.sk
It's no shame to ask for an answer if all efforts failed.
But it's awful to ask without any effort to find the answer yourself.

Post Reply