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 9142843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:52:39+00:00 2026-06-17T09:52:39+00:00

My question is that how can I disable options in the create drop down

  • 0

My question is that how can I disable options in the create drop down menu below if the start date $dbSessionDate and Start Time $dbSessionTime are before the current date and time?

Below is the drop down menu where data is fetched from database using mysqli:

while ( $sessionqrystmt->fetch() ) {

$time_string = $dbSessionDate." ".$dbSessionTime;
$time_from_string = strtotime($time_string);    
if($time_from_string > date("Y-m-d H:i:s"))
{
$sessionHTML .= sprintf("<option value='%s'>%s - %s - %s</option>", $dbSessionId, $dbSessionName, date("d-m-Y",strtotime($dbSessionDate)), date("H:i",strtotime($dbSessionTime))) . PHP_EOL;    
}else{
$sessionHTML .= sprintf("<option value='%s' disabled>%s - %s - %s</option>", $dbSessionId, $dbSessionName, date("d-m-Y",strtotime($dbSessionDate)), date("H:i",strtotime($dbSessionTime))) . PHP_EOL;   

}
}

UPDATE:

HTML from view Source:

<select name="session" id="sessionsDrop">
<option value="">Please Select</option>
<option value='28'>LDREW - 09-01-2013 - 09:00</option>
<option value='29'>BQNYF - 10-01-2013 - 10:00</option>
<option value='22'>WDFRK - 17-01-2013 - 09:00</option>
<option value='26'>POKUB1 - 25-01-2013 - 15:00</option>
</select>
  • 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-17T09:52:41+00:00Added an answer on June 17, 2026 at 9:52 am

    Use strtotime(). Combine $dbSessionDate and $dbSessionTime together, pass it to the function strtotime, then compare the resultant variable to date().

    Code:

    $time_string = $dbSessionDate." ".$dbSessionTime;
    $time_from_string = strtotime($time_string);
    
    if($time_from_string > strtotime(date("Y-m-d H:i:s")))
    {
       //Do whatever you like to do.
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The answer to this SO question says that you can create an api by
I have a question that can I use AS400ConnectionPool in Spring if then pls
Just a quick question that I can't seem to find a proper answer to
I have a quick question that I can't seem to find online. I am
This is a really silly question that I can't fine a difinitive answer to.
This is a super simple question that I just can't seem to find a
I'm asking and answering this question so that I can find it again in
Before somebody points me to that question, I know that one can't parse html
I am using ANTLR 3 , I have a question is that How can
I was hoping if anyone can answer a fundamental question that I have regarding

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.