Adding to the date to take it to midnight time

Let’s say I have the dates 2008-12-21 3:40:11 , 2007-01-23 2:30:11 in the database. Now I want to change these dates to the midnight date 2008-12-21 00:00:00, 2007-01-23 00:00:00. How should I do this? Currently I’m exploding these dates into an array with ‘space’ as a delimiter, further exploding the first element of the array (e.g. 2008-12-21) by using dash (-) as a delimiter, then concatenating it with "00:00:00’ to produce the date. While this is doing the job, I have a feeling it’s an amateurish way of handling it. Is there some better way? Also, how do I take it to the next midnight i.e. 2008-12-22 00:00:00 in the first example. Again, I’m able to do it but with exploding arrays. Is there some other way?


If the time doesn’t interest you, you could extract only the date from the database using DATE().

That solved it. Thanks!