josh42 Posted February 23, 2014 Share Posted February 23, 2014 I noticed that the NOW() function in chapter 12 only returns time in YYYYMMDD format. Maybe this is the format the database needs, but it creates a problem if I add multiple blog posts a day. The newest ones aren't at the top because NOW() doesn't include minutes and seconds. Is there a better way to send time information to the database? Thank you. Link to comment Share on other sites More sharing options...
HartleySan Posted February 23, 2014 Share Posted February 23, 2014 Hello, and welcome to the forums. I'm not sure if your software is configured differently from normal, but every system I have ever used has added hours, minutes and seconds to the time whenever you use NOW(). Is the issue, by chance, the fact that when you format the date and time retrieved from the DB, you're only grabbing the year, month and date? Link to comment Share on other sites More sharing options...
Antonio Conte Posted February 23, 2014 Share Posted February 23, 2014 I think you are using the type "Date" instead of "DateTime" on your DB columns. NOW() should return both date and time when using DateTime. 2 Link to comment Share on other sites More sharing options...
Joel Posted March 5, 2014 Share Posted March 5, 2014 Both DateTime and TimeStamp return date and time with NOW() for me Link to comment Share on other sites More sharing options...
josh42 Posted March 16, 2014 Author Share Posted March 16, 2014 Yes, the issue was my db column was set to 'date'. Switching to 'datetime' fixed the problem. Thank you! Link to comment Share on other sites More sharing options...
Recommended Posts