Ginxxx
Ginxxx

Reputation: 1648

Compare date() to timestamp PHP

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.

Upvotes: 0

Views: 72

Answers (1)

Mike Foxtech
Mike Foxtech

Reputation: 1651

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

Upvotes: 1

Related Questions