Date comparison - Less than 24 Hours in Models |
-
Anharr Junior Member
 
-
Posts: 11
Threads: 5
Joined: May 2024
Reputation:
0
(06-13-2024, 02:40 AM)paulkd Wrote: (06-12-2024, 09:32 AM)Anharr Wrote: I have the following queries in CodeIgniter to find any data in which the date_created field is less than 24 hours.
Here is my code in Models
Code: public function checkDeposit($preOrder)
{
return $this->db->table('deposit')
->where('preorder_code', $preOrder)
->where('status', 0)
->where('date_created <', strtotime(date('YmdHis'), INTERVAL 1 DAY))
->get()
->getRowArray();
}
But the above query is not working.
What I want in short is, return all rows which the date_created is less than 24 hours.
My date_created format is Unix TimeStamp (1718204380)
How to get data less than 24 hours in Models ?
Hi,
I'm not sure I fully understand your requirements but I think the following would bring back records "within the past 24 hours"
Code: ->where('date_created >', strtotime("-1 day"))
Greaatttt ! Thank you !
|
Messages In This Thread |
RE: Date comparison - Less than 24 Hours in Models - by Anharr - 06-13-2024, 02:43 AM
|