Forum for discussing general topics related to Couch.
9 posts Page 1 of 1
Halo.

I've got issues about blog publish date.

First, I write my code
<cms:date k_page_date format='%X %d %B %Y' locale='indonesian' />
and the result is in the front-end is "8:56:01 16 Juli 2015" while the actual time where I am is "10:26 AM 16th July 2015".

Then, I want to find out whether the time "8:56:01" shown in the front-end is AM or PM, so I add "%p" into the 'format' and it yields the same as before, yes, no 'AM/PM' shows. I replace "%p" with "%P", the whole part of date & time in the front-end disappears instead.

So how am I supposed to write the code so the time/date shown in the front-end will be "10:26 AM 16 Juli 2015"?

Thank you.
Hi,

As per PHP's documentation, the following format should show the date in the form you indicated -
Code: Select all
<cms:date k_page_date format='%I:%M %p %d %B %Y' locale='english' />
The code above results in 11:42 AM 27 June 2015

However, as soon as the locale is changed to 'indonesian', the 'AM' part of the date disappears -
Code: Select all
<cms:date k_page_date format='%I:%M %p %d %B %Y' locale='indonesian' />
results in 11:42 27 Juni 2015

So you are right, there is some kind of bug (feature?) with the underlying PHP functions.

As a workaround, I used the following -
Code: Select all
<cms:date k_page_date format='%I:%M %p' /> <cms:date k_page_date format='%d %B %Y' locale='indonesian' />
which results in 11:42 AM 27 Juni 2015

So that should be the solution for your problem.

As for the first problem you mentioned -
result is in the front-end is "8:56:01 16 Juli 2015" while the actual time where I am is "10:26 AM 16th July 2015".

I think that discrepancy is because you did not set your timezone in couch/config.php which by default is set to -
Code: Select all
define( 'K_GMT_OFFSET', +5.5 ); 


That said, if you change the timezone now it will only affect the files that you create from this moment on. You'll need to tweak the publish date of all existing pages manually.

Hope it helps.
Halo KK. I just begun working page blog right now.

Your solution worked perfect, but only in localhost. When I uploaded it to my hosting server online, the locale attribute seemed kinda ignored and it got set to default: the month "Juli (Indonesian)" changed back to "July (apparently English)".

Well, I thought it might be only 'locale' of my country that was troubled, so in order of testing the error I tried to change the locale='indonesian' to locale='malay'. It worked (in localhost), the 'Juli (Indonesian)' changed to 'Julai (Malay)', but when I uploaded it to server online, it then was no 'Julai' but the default 'July'.

What is wrong KK?

Thanks.
@Herza, that can only mean that your server does not support the locales you mentioned.
As mentioned in the docs, this feature relies on the server having support for the involved locale.

Perhaps you can try contacting your host and request to add this locale?
How do we know that the host has feature local or not? My host said that the hosting locale has been set to Jakarta/Asia, but it still doesn't work. While in local host I tweaked nothing but it can work just fine (how can localhost support locale? Where do we see locale feature in local host, anyway?). How come?
Ah, i forgot to say thanks :D
You are welcome :)

Since your provider assures that the locale is available, please try using the following values for the locale (hopefully one of them will work).
<cms:date k_page_date format='%d %B %Y' locale='id_ID' />

<cms:date k_page_date format='%d %B %Y' locale='id_ID.UTF-8' />

<cms:date k_page_date format='%d %B %Y' locale='id' />

<cms:date k_page_date format='%d %B %Y' locale='ind' />

Do let me know if it helps.
Awesome! The first two work like a charm >_< ! The other two don't. It's solved!

Thanks again KK! :D
I'm glad it worked, Herza :)
9 posts Page 1 of 1
cron