Showing date

Ask the community for help with CE Phoenix Cart.
Post Reply
User avatar
Pierre_P
Posts: 119
Joined: Fri Mar 12, 2021 5:06 am
Has thanked: 12 times
Been thanked: 5 times

Showing date

Post 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?
burt
Lead Developer
Lead Developer
Posts: 2956
Joined: Tue Oct 29, 2019 9:37 am
Has thanked: 52 times
Been thanked: 167 times

Re: Showing date

Post 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
User avatar
Pierre_P
Posts: 119
Joined: Fri Mar 12, 2021 5:06 am
Has thanked: 12 times
Been thanked: 5 times

Re: Showing date

Post by Pierre_P »

Thanks @burt
I need new looking glasses, i was staring at this.
Used D j M G:i and shows perfectly.
Post Reply