Home > Net >  Compare date() to timestamp PHP
Compare date() to timestamp PHP

Time:11-03

Is there a way that I can compare a day with date()on php and timestamp() on db like this

example:

date(); has this value 2021-11-02

timestamp() has this value 2021-11-02 11:00:52

here's my code

$current_date = date("Y-m-d");
$fetch_user_by_number = "SELECT id,transfer_amount,number FROM `transfer_wallet` WHERE `transfer_number`=:number AND `transaction_date` ORDER BY `transaction_date` DESC limit 1";

What I am trying to do is create a push notification on my App that whenever a new data arrived at my db i will push notify the user on my application.

I am just kind of lost on the comparison of date stuff. Any logic or idea will be very appreciated . Thank you.

CodePudding user response:

Try like this

SELECT `id`, `transfer_amount`, `number` 
FROM `transfer_wallet` 
WHERE `transfer_number`= :number 
  AND `transaction_date` >= now() 
ORDER BY `transaction_date` DESC limit 1
  • Related