- Posts: 224
- Thank you received: 8
How ot customize the date format in products comments
I see that the date format in products comments is handled by the language string
HIKASHOP_EXTENDED_DATE_FORMAT="%d.%m.%Y - %H:%M"
I woudl like a different format (like 20 May 2018), but if I change that language string this will affect the date format on orders/invoices etc... whcih instead should stay %d.%m.%Y - %H:%M
so how to do this?
in vote / listing.php file I see this code
could you suggest maybe how to edit it in order to pull a different language string?
thank you!
Please Log in or Create an account to join the conversation.
You can just change the line:
echo hikashop_getDate($vote->vote_date);
to:
echo hikashop_getDate($vote->vote_date, '%d.%m.%Y - %H:%M');
and replace %d.%m.%Y - %H:%M by the format you want:
us2.php.net/strftime/
Please Log in or Create an account to join the conversation.
I tried this but it's not working unfortunately.
I inserted
should show 22 May 2018
but it still shows 22.05.2018
I tried to insert some new comments to see if this would change only in the new ones,
I have also verified that the vote / listing.php is rendering the changes correctly, tried to add a test paragraph and it shows
so what could this be?
Please Log in or Create an account to join the conversation.
Make sure that you're editing the correct view file wih the "Display view files" setting of the HikaShop configuration.
It should indeed be vote/listing.php
Make sure that you're editing it for the correct template.
Also, note that the %d %B %Y format is a default format and thus if you use that, it will automatically use the translation key:
HIKASHOP_DATE_FORMAT="%d %B %Y"
So either you change that translation key, or instead of the format, you use a new translation key and you enter the format for that translation key in your translation override so that the system can use it.
Please Log in or Create an account to join the conversation.
so I inserted a language string
these are all other language strings I have on file
when I change
but as soon as I change it back to
so I am confused here...because if I change the language string to
HIKASHOP_DATE_VOTE="%Y"
then I correctly see just the year
but as soon as I change it to
HIKASHOP_DATE_VOTE="%d %B %Y"
I see: 22.05.2018
while it should be: 22 May 2018
this is truly a mistery to me!
Please Log in or Create an account to join the conversation.
‘d.M.y – h.i’
d = day as 2 digits
M = month as 3 letters i.e. Jan
F = month in full i.e. January
y = year as 2 digits i.e. 18
Y = year as 4 digits i.e. 2018
h = hour in 12 hour format
I = minutes
This works for me but don't know if its the best way.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
No, you need to pass the translation key, not the text.
So the code should be for example:
Please Log in or Create an account to join the conversation.
if I insert this
%02 %482 %2018
if I insert this
02.04.2018
while it should be
2 Apr 2018
because the language string is
Please Log in or Create an account to join the conversation.
I don't see why it would do that.
Then simply use instead the date function of PHP with the format you want:
php.net/manual/fr/function.date.php
Please Log in or Create an account to join the conversation.
I have already tried
echo hikashop_getDate($vote->vote_date, '%d %B %Y');
see third reply on this same post
It still renders 02.04.2018 and not 2 Apr 2018
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
I am not a developer and I don't always understand fully what you mean
This finally did the trick and now the votes date is showing correctly
thanks again!
Please Log in or Create an account to join the conversation.