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

  • Home
  • SEARCH
  • 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 7937211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T22:28:02+00:00 2026-06-03T22:28:02+00:00

hi i stored a date that is taken from form in a variable using

  • 0

hi i stored a date that is taken from form in a variable using php and now i want to check whether the date is in the season or not..
the code i written is as follows:

$year = 2012;
$month1 = $_POST["month1"];
$date = $_POST["date"];
$result = "{$year}/{$month1}/{$date}";
echo $result;

and now

// finding first saturday in febraury
    $saturday = strtotime('First Saturday '.date('F o', mktime(0,0,0, $month, 1, $year)));
    echo "this is the first saturday in the given year:";
    echo date('Y/m/d', $saturday);

 // calculating first 12 weeks after the first saturday
    echo "<br/>";
    $season1 = strtotime ( '+12 week' , $saturday);
    echo "<br/>this is the first season:";
    echo date('Y/m/d', $season1);
    echo "<br/>";

 // calculating the one week gap after the first 12 weeks
    $season2 = strtotime ('+1 week' , $season1);
    echo "<br/>this is the first week break:";
    echo date('Y/m/d', $season2);
    echo "<br/>";

Here what i need to do is to check whether the date given by the user is in season1 or season2..for doing so i tried as

if ($result <= $season1)
    {
     echo "League yet to be opened";
    }
    else 
    {
    echo "league 1 is opened";
    }

but the condition is not checking here, and like wise i need to check the date entered by the user with 8 seasons how can i do that….any help is much appreciated….thanks in advance..

  • 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-03T22:28:03+00:00Added an answer on June 3, 2026 at 10:28 pm

    I’d advice you use such organisation of code and logic

    Define current date from POSTed

    Don’t forget to became sure data is safe

    Year, month and date (day) MUST be numerical, for this logic to work.

    $year = 2012;
    $month1 = $_POST["month1"];
    $date = $_POST["date"];
    

    Define your seasons array

    $seasons = array(
       1 => array(
                  'season_name' => 'first_season',
                  'year_start' => 2012, 'year_end' => 2012, 
                  'month_start' => 1, 'month_end' => 2, 
                  'day_start' => 10, 'day_end' => 20
                  ), 
       2 => array(
                  'season_name' => 'second_season',
                  'year_start' => 2012, 'year_end' => 2012, 
                  'month_start' => 2, 'month_end' => 3, 
                  'day_start' => 30, 'day_end' => 15
                  ) 
     );
    

    Process data to define season

    $season_match = array();
    foreach($seasons as $season){
       if($year >= $season['year_start']) && if($year <= $season['year_end']){
           if($month >= $season['month_start']) && if($season<= $season['month_end']){
               if($date >= $season['date_start']) && if($season<= $season['date_end']){
                   $seasons_match[] = $season['season_name'];
               }
           }
       }
    }
    

    Test for errors and echo resulting season

    if(count($season_match) == 0){
       echo 'Date is out of any season';
    }
    esleif(count($season_match) >1){
       echo 'ERROR: Date can be for more then one season at once';
    }
    else{
       echo $season_match; // This is the name of our season!
    }
    

    It’s general logic for simple and clear solution of your task, I haven’t tested it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Microsoft Access database for storing data. In that, I stored date
I have a function that returns a date from a stored procedure, and it
I have a core data context with objects that have a date stored in
I have dates stored in MongoDB using Date(), MongoDB uses UTC it's date type,
I have some tasks on a site in php using nginx that I'm trying
I need a PHP script that will find the date of the oldest file
I have a model and store that take in values from my form fields.
I have a stored procedure that takes data from multiple tables. The stored procedure
I currently use SQL2008 where I have a stored procedure that fetches data from
I have a stored proc that takes a date a string parameter. The data

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.