You need to tell it what day to use. Try this:
$days = date('t', time());
$month = date('m',time());
$year = date('Y',time());
$last_date = strtotime("$year-$month-$days 00:00:01");
$last_date_ordinal = date('tS',$last_date);
print 'The ' . $last_date_ordinal . ' is the last day of this month';
Quite a lot of hassle for four characters, but there you go.
If you know what the first of next month is, you can count back one
day to get the last day of this month as well. For example, this will
return 28th (of this February):
date('tS',strtotime('2011-03-01 - 1 day'));
So we could try this:
$next = explode('-',date('Y-n-01'));
$next[1] = ($next[1] + 1 > 12) ? 1 : $next[1] + 1;
date('tS',strtotime(implode('-',$next) . ' - 1 day'));
Let me know how that works.
Walter
On Feb 23, 2011, at 5:37 PM, DeltaDave wrote:
I am using
echo date(‘t’);
To display the no of days in the current month
I would also like to display the ordinal that goes with it
ie if there are 30 days in the month it would show ‘30th’
If I use
echo date(‘tS’); I just get the ordinal for today
Is there a similar shortcut or am I going to have to do some sort of
lookup/calculation?
David
dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options
dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options