I want to get the date for current date in php. what i tried is here...
echo $x."<br>";
echo date("D",$x)."<br>";
But the output was
21-02-10
Thu
It is giving correct date but not the correct day value.Why..?
What I want day is the date for monday for the current week which can be generated on any day of the week. so what I did was, I'm taking the today's day and comparing with (Mon,Tue.... Sun) and respectively creating a timestamp using
case "Mon":
$startdate1=date("d-m-y");
$parts = explode('-',$startdate1);
$startdate2 = date('d-m-Y',mktime(0,0,0,$parts[1],($parts[0]+1),$parts[2]));
$startdate3 = date('d-m-Y',mktime(0,0,0,$parts[1],($parts[0]+2),$parts[2]));
$startdate4 = date('d-m-Y',mktime(0,0,0,$parts[1],($parts[0]+3),$parts[2]));
$startdate5 = date('d-m-Y',mktime(0,0,0,$parts[1],($parts[0]+4),$parts[2]));
$startdate6 = date('d-m-Y',mktime(0,0,0,$parts[1],($parts[0]+5),$parts[2]));
$startdate7 = date('d-m-Y',mktime(0,0,0,$parts[1],($parts[0]+6),$parts[2]));
$dates=array(1 => $startdate1,$startdate2,$startdate3,$startdate4,$startdate5,$startdate6,$startdate7);
$i=1;
while( $i <= 7 )
{
echo $dates[$i];
$i++;
}
break;
$date is the final array respective to today that has to be returned. Is there any other better method to do this operation.