MyBB Community Forums

Full Version: Month and Date
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello everyone, I have some questions regarding M (month) and d (Date)
so I have a portal page which shows recent threads, and I made a small box which shows is supposed to show the M and d (php)
I have tried many ways to get the thread creation M and d, but there is no way possible
I tried making a variable:

$annmonth = my_date(M);
This code shows the real-time month, not the thread creation month.
Also:

$annmonth = my_date(d);
shows the whole thing (date, month, time, yesterday or whatever)
Is there anyway to get only the month and date of the thread?
Why not just do

// Returns for example: 11-30-2016, 07:53 PM or 3 hours ago
$annmonth = my_date('relative', $thread['dateline']);
First of all the portal page contains $announcements['dateline']
Second of all the code you pasted above isn't working unfortunately
BUT, thank you so much for having your time and and sorry but it didn't work,
Any other way?
(12-04-2016, 03:27 PM)JoblessCat Wrote: [ -> ]I have tried many ways to get the thread creation M and d, but there is no way possible
I tried making a variable:

$annmonth = my_date(M);
This code shows the real-time month, not the thread creation month.
Also:

$annmonth = my_date(d);
shows the whole thing (date, month, time, yesterday or whatever)
Is there anyway to get only the month and date of the thread?

Because you haven't given it a date to format, so it just uses the current date.

You need to pass through the date you actually want to format as the second parameter:

$month = my_date('M', $announcements['dateline']);
$day = my_date('d', $announcements['dateline']);
Thank you so much it worked, also for the fast reply