Showing date

Open to all! Ask other shopowners for help.
Post Reply
User avatar
Pierre_P
Contributor
Posts: 144
Joined: Fri Mar 12, 2021 5:06 am
Phoenix Version: v1.1.0.6
Has thanked: 21 times
Been thanked: 11 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?


Join The Code Co-op to get access to your library in the Code Co-op Forum
User avatar
burt
Core Team
Posts: 4551
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 252 times
Been thanked: 412 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
I am not here to build for you.
I am here to build with you. Let's help each other.
User avatar
Pierre_P
Contributor
Posts: 144
Joined: Fri Mar 12, 2021 5:06 am
Phoenix Version: v1.1.0.6
Has thanked: 21 times
Been thanked: 11 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.


Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply