Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8431737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:56:10+00:00 2026-06-10T05:56:10+00:00

I am trying to calculate, based on today’s date (24 August 2012), the following

  • 0

I am trying to calculate, based on today’s date (24 August 2012), the following three values:

  1. Date of this month’s first Saturday.
  2. Date of this month’s third Saturday.
  3. Date of next month’s first Saturday.

This is how I do it in PHP script:

// Returns August 2012
$this_month = date("F Y");

// Returns September 2012
$next_month = date("F Y", strtotime("next month"));

// Returns August 04th, Saturday
$t_sat_1st=date('U', strtotime($this_month.' First Saturday'));

// Returns August 18th, Saturday
$t_sat_3rd=date('U', strtotime($this_month.' Third Saturday'));

// Returns September 08th, Saturday
$n_sat_1st=date('U', strtotime($next_month.' First Saturday') );

Why is the wrong date returned for the last line of code? I expect it to return September 1st, 2012. What is wrong with my code?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T05:56:11+00:00Added an answer on June 10, 2026 at 5:56 am

    I don’t know why your code doesn’t exactly work, must be the way it is parsed..
    but try

    $n_sat_1st=date('U', strtotime('first saturday of ' . $next_month) )
    

    Note the ‘of’ it is necessary.
    This code will only work in 5.3+

    It should be noted that apparently some of these strings only work in PHP 5.3 apparently, notably:

    “first day of this month” and “last day of this month” for example.
    According to information found on another website, the “xxx day of”
    feature was added in PHP 5.3.

    Comment on this page – http://www.php.net/manual/en/datetime.formats.relative.php

    I have tested this on both windows and ubuntu both php 5.3 and 5.4 and it works.

    If this does not work, try this

     $d = new DateTime($next_month);
     $d->modify('first saturday of this month');
     echo $d->format('U');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to conditionally calculate some values based on user inputs in a
I was trying to determine a good way to calculate a previous date based
I'm trying to calculate a form based on values provided, I've written the script
Hey I am trying to calculate monthly repayments based on loan amount, interest rate
I am trying to calculate the sub_total field based on: total_full + total_half. however
I'm trying to calculate the sunset / rise times using python based on the
I'm trying to calculate the necessary height for a cell in a tableview based
I'm trying to calculate somebody's bowel health based on a points system. I can
I am trying to calculate value $x in a number series based on an
I'm trying to calculate how WIDE to make my button, based on the text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.