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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:20:25+00:00 2026-06-14T08:20:25+00:00

So in my php script I compare the current time (date()) with the time

  • 0

So in my php script I compare the current time (date()) with the time from the mysql database but it doesn’t work. How do I do this?
PHP

if($row['Datum'] < date(Y-m-d-H-i-s)) { Code to execute}

Mysql DATETIME

2012-11-13 17:00:00
  • 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-14T08:20:26+00:00Added an answer on June 14, 2026 at 8:20 am

    Your current code has syntax errors, but it’s pretty close to something that would work:

    if ($row['Datum'] < date('Y-m-d H:i:s')) {
        // Code to execute
    }
    

    This is likely to be inside a loop, so you should cache the output of date():

    $now = date('Y-m-d H:i:s');
    
    // loop here
    foreach ($rows as $row) {
        if ($row['Datum'] < $now) {
            // code to execute
        }
    }
    

    You could also do the comparison directly in the query:

    $now = date('Y-m-d H:i:s');
    $db->query("SELECT * FROM whatever WHERE Datum < '$now'");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to write a php script to compare rows from the database and
Im writing a php script to compare the similarity of 2 strings. This works
I need to use PHP to copy data from one MySQL database to another.
I make an AJAX GET request to a PHP script to compare a value
My PHP script is displaying the wrong time. For eg. the time on my
A php script is giving this array (which has been passed through json_encode() )
I need to compare (actually rank/sort) dates in a PHP script. The dates are
I'm making a script that will hopefully be mainly PHP so it doesn't require
I have the field datetime with DATETIME type in MySQL. In PHP script I
PHP script to read in user action requests and parse them to their components.

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.