Page 1 of 1

Showing date

Posted: Mon Dec 09, 2024 7:52 am
by Pierre_P
I created a pi module to show the customers when a special price will expire.
Showing the expiry date is bit wrong - example the expiry date is set as 2024-12-30 23:59:59 as in the database, the result for the customers is showing Mon 09 Dec 09:12 (the 09 part as day)

The code is

Code: Select all

<?= sprintf(PI_SPECIALS_EXPIRY_TEXT, date('D d M h:m'), $special['expires_date']) ?>
If i use expound or abridge then it shows correct date - example Monday, December 30, 2024
Figures there's an issue on how i tried to use D d M

My question will be how to fix and show shortened Month name?

Re: Showing date

Posted: Mon Dec 09, 2024 9:35 am
by burt
D: 3 character representation of Day, eg "Sat", "Sun" etc
d: 2 number representation of Day, eg "10", "24"
M: 3 character representation of Month, eg "Mar", "Dec" etc
h: 2 number representation of Day, eg "09", "30" etc
m: 2 number representation of Month, eg "03", "12" etc

Therefore your D d M h:m will result in (for now "Monday 9th December at 09:30");

Mon 09 Dec 09:12
Which is 3 Letter Day, 2 number Day, 3 letter Month, 2 number Month, 2 number Day

Read more:
https://www.php.net/manual/en/function.date.php
Particularly:
Example #4 date() Formatting

Re: Showing date

Posted: Mon Dec 09, 2024 1:05 pm
by Pierre_P
Thanks @burt
I need new looking glasses, i was staring at this.
Used D j M G:i and shows perfectly.