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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:10:44+00:00 2026-05-22T03:10:44+00:00

I am using the following code to attempt to compare the current date with

  • 0

I am using the following code to attempt to compare the current date with a date entry in a mySql database. It’s code that I have found online and adapted as all the examples I have found hard-code the date to compare the current date with.
The trouble is even dates in the future are being marked as expired and I can’t understand why this would be.
I am afraid that I am still new to PHP, so I may be making a schoolboy error!

$exp_date = KT_formatDate($row_issue_whatson1['dateToShow']);
$todays_date = date("d-m-Y");
$today = strtotime($todays_date);
$expiration_date = strtotime($exp_date);
if ($expiration_date > $today) { echo "Not expired"; } else { echo "expired"; }

Any help would be most appreciated.

I should add that the date time format used in the database entries is dd/mm/yyyy

  • 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-05-22T03:10:45+00:00Added an answer on May 22, 2026 at 3:10 am

    Instead of making a string then converting it to a timestamp, simply use mktime:

    <?php
    $today = mktime(
        0, // hour
        0, // minute
        0 // seconds
    );
    ?>
    

    The rest of the values will be filled according to today’s date. If this still gives problems, put in some echo’s for the values of $exp_date and $expiration_date.

    Edit

    Since this solved the problem, the discrepancy you were seeing was because you were doing the opposite with date(‘d-m-Y’). You were asking for the current date and the time values are then filled in with the current time. The expiration date in the database is likely set at midnight. With both dates being equal, and it being say 11am now, you are comparing if (00:00:00 > 11:00:00) which fails.

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

Sidebar

Related Questions

I am using the following code to attempt to read a large file (280Mb)
I'm using the following code to query a database from my jsp, but I'd
I am using following PHP code to connect to MS Access database: $odb_conn =
I am using the following code to attempt to redirect a dynamic URL to
I'm using the following code in an attempt to show a dialog with a
I'm using the following code in an attempt to programatically allow the NetworkService account
I have the following code: #include <iostream> #include <string> #include <unistd.h> using namespace std;
I need to connect to a remote MySQL database and have created the following
I'm using the Obout.com MVC controls and have included the following code in one
Using the following code I get a nice formatted string: Request.QueryString.ToString Gives me something

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.