scooter41
asked on
Display all dates of current month
Hi There,
I have a current mysql database, with a registered date field.
What my client wants to do is to display the current dates of this month, and display the date in bold if it is the registered date.
So for example:
April
01, 02, 03, 04, 05, 06, 07,<b> 08 </b>, 09, 10, 11, ..... 31
So I guess it would need to just loop through the dates of this month (28, 30, or 31 : month dependent) and just check on each loop if it = registered date
I have a current mysql database, with a registered date field.
What my client wants to do is to display the current dates of this month, and display the date in bold if it is the registered date.
So for example:
April
01, 02, 03, 04, 05, 06, 07,<b> 08 </b>, 09, 10, 11, ..... 31
So I guess it would need to just loop through the dates of this month (28, 30, or 31 : month dependent) and just check on each loop if it = registered date
Also it's more effective to create an array of days of the month (from 1 to 31),
then select entire month,
then do loop for registered dates (record-by-record) and set "<b>" "</b>" in appropriate array position,
then output from 1 to the last day of your month.
then select entire month,
then do loop for registered dates (record-by-record) and set "<b>" "</b>" in appropriate array position,
then output from 1 to the last day of your month.
ASKER
I like the idea of the array, then loop, is there an easy way to get the current number of days in the current month..... in perhaps cgi or is it best to do in a mysql statement
current number of days in the current month is better to be calculated in CGI.
So you don't need extra SQL requests just for data, that can be calculated locally.
What language are you using?
So you don't need extra SQL requests just for data, that can be calculated locally.
What language are you using?
ASKER
Perl, thanks for your help so far, this is starting to make clearer sense now
I'm not a perl guru, but something like this:
use Time::Local;
$now_time=gmtime();
$next_month=timegm(0,0,0,1 ,($now_tim e->mon+1) % 12, $now_time->year + (($now_time->mon+1)/12) );
$this_month=timegm(0,0,0,1 ,$now_time ->mon,$now _time->yea r);
$days_between=($next_month -$this_mon th)/60/60/ 24;
use Time::Local;
$now_time=gmtime();
$next_month=timegm(0,0,0,1
$this_month=timegm(0,0,0,1
$days_between=($next_month
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks heaps for your support, in this hour of need :)
For February you may always use 29
OR
if you like things to be more complex, substract 1-Mar from 1-Feb and get number of days of current year.