MySQL: Curdate() vs Now()
What is difference between MySQL Curdate()
and Now()
?
For questions like this, it is always worth taking a look in the manual first. Date and time functions in the mySQL manual
CURDATE()
returns the DATE part of the current time. Manual on CURDATE()
NOW()
returns the date and time portions as a timestamp in various formats, depending on how it was requested. Manual on NOW().
Just for the fun of it:
CURDATE() = DATE(NOW())
Or
NOW() = CONCAT(CURDATE(), ' ', CURTIME())
CURDATE()
will give current date while NOW()
will give full date time.
Run the queries, and you will find out whats the difference between them.
SELECT NOW(); -- You will get 2010-12-09 17:10:18
SELECT CURDATE(); -- You will get 2010-12-09