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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.