CodeIgniter Forums
Current date in where query - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: General Help (https://forum.codeigniter.com/forum-24.html)
+--- Thread: Current date in where query (/thread-64760.html)



Current date in where query - doomie22 - 03-22-2016

Hi all,

I am just trying to get some results to only show upcoming events only.  So I am trying to get it to get the date that someone is looking at the page and grab from that date onward.

PHP Code:
$this->db->where('date >='DATE()); 

I have tried to use this that people online have said to use but I just get errors and I have tried NOW(), GETDATE() and nothing seems to work.

Doomie


RE: Current date in where query - keulu - 03-22-2016

if your field is a datetime, you can use
PHP Code:
date('Y-m-d H:i:s'

if your field is a timestamp, you can use
PHP Code:
time()