Jump to content

Days in the month


xionhack

Recommended Posts

Yapee! I got the solution

 

<?php
$from = date('d-D',strtotime('-1 second',strtotime('+1 month',strtotime(date('m').'/01/'.date('Y').' 00:00:00'))));
$pices = explode('-',$from);
if($pices[1] == "Sat")
{
$p= "SSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFS";
} else if($pices[1] == "Sun")
{
$p= "SMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTF";
} else if($pices[1] == "Mon")
{
$p= "MTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWT";
} else if($pices[1] == "Tue")
{
$p= "TWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTW";
} else if($pices[1] == "Wed")
{
$p= "WTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMT";
} else if($pices[1] == "Thr")
{
$p= "TFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSM";
} else if($pices[1] == "Fri")
{
$p= "SMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSS";
} else {
$p= "LOL! Out of earth LOL! Out of earth LOL! Out of earth LOL! Out of earth LOL! Out of earth";
}
echo substr("$p", -$pices[0]);
?>

 

Currently its automatic you can update // strtotime(date('m').'/01/'.date('Y') // this to get magic string of your month.

 

Link to comment
https://forums.phpfreaks.com/topic/208612-days-in-the-month/#findComment-1090006
Share on other sites

Could be simplified and it needs some error checking for the args, but here's a quick way:

 

function get_days($month, $year) {

for($date=strtotime("$year-$month-1"); date('n', $date) == $month; $date=strtotime("+1 day", $date)) {
	$days[] = substr(date('D', $date), 0, 1);
}
return implode($days);
}

echo get_days('7', '2010');

Link to comment
https://forums.phpfreaks.com/topic/208612-days-in-the-month/#findComment-1090993
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.