hye..
i have a problem to display only numbers of date according the month automatically. I want to display in the table like this

date 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17............31

Recommended Answers

1. get month and year.
2. get a unix timestamp for the first day of that month using mktime().
3. get the number of days in the month with date('t')
4. Make days into a range with range(1,$no_days)

An all-in-one:

$month = 2; 
$year = 2008; …
Jump to Post

All 3 Replies

Member Avatar

1. get month and year.
2. get a unix timestamp for the first day of that month using mktime().
3. get the number of days in the month with date('t')
4. Make days into a range with range(1,$no_days)

An all-in-one:

$month = 2; 
$year = 2008;

$days = range(1,date('t',mktime(0,0,0,$month,1,$year)));
print_r($days);

Actually i want to display the dates depends on month.
for example,in this month (december) have 31days so i want to display that days in the html table .i.e

date | 1 | 2 | 3 |.....................|31 |

Member Avatar

It's what I gave you. To display like this:

$month = 2; 
$year = 2008;
 
$days = range(1,date('t',mktime(0,0,0,$month,1,$year)));
echo "|" . implode("|",$days) . "|";
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.