-2

I want to compare datetime column in mysql db with today.

Actually I want to add an if string, so if the return result is greater than a given number, it does something, and if it's smaller it does something else.

Can you help me out here?

Scath
  • 3,777
  • 10
  • 29
  • 40
  • 2
    Show us what you got so far and we can start a conversation – Dale Apr 06 '18 at 13:25
  • 2
    Please read: [How to create a Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve) and improve your question. – An economist Apr 06 '18 at 13:33
  • Possible duplicate of [Datetime equal or greater than today in MySQL](https://stackoverflow.com/questions/5182275/datetime-equal-or-greater-than-today-in-mysql) – Pascal Apr 06 '18 at 13:41

2 Answers2

0

fetch DateTime from the database and compare with PHP default function now(). for make condition use if condition.

Ijaz Ali
  • 60
  • 6
0

Sorry guys, for the late reply, but I managed to figure it out myself... Here is the result:

$date1 = date_create($row["column"]);
                $date2 = date_create(date("Y-m-d");
                $interval = date_diff($date1, $date2);
                if ($interval->format('%R%a days') < 350) { echo '<td class="column-table">';
                echo $interval->format('%R%a days'); 
                echo '</td>';
        }

Sorry for the inconvenience.