Jump to content

Every Friday in the month


PyraX

Recommended Posts

<?php
$month = 1; //supply month #
$year = 1998; //supply year

$date = mktime(0, 0, 0, $month, 0, $year);
$i = 1;
$days = date("t", $date);

while ($i <= $days) {
    $find_date = mktime(0, 0, 0, $month, $i, $year);
    if (date("l", $find_date) == "Friday") {
        echo "Day $i is a Friday on month #$month.<br />";
    }
    $i++;
}
?>

 

Edit: Works fine :P.

Link to comment
Share on other sites

Thanks so much DJTim666

 

Here is the final code:

 

$month = $m; //supply month #
$year = $y; //supply year
$timestamp = strtotime("$m/01/$y");
$date = mktime(0, 0, 0, $month, 0, $year);
$i = 1;
$days = idate("t",$timestamp);

while ($i <= $days) {
    if (date("l",strtotime("$m/$i/$y")) == "Friday") {
        echo "Day $i is a Friday on month #$month<br>";
    }
$i++;
} 

Link to comment
Share on other sites

I know it says solved, but I don't think you got the updated script. You don't need all that strtotime stuff in your re-written script. mktime returns the timestamp of the month/year/day/hour/minute/second supplied.

 

Anyways, glad I could be of help :P.

 

--

DJ

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.