Prodigal Son Posted July 10, 2008 Share Posted July 10, 2008 Is there any difference from using mysql now() to insert a date vs. using php time()/mktime() and then date? What's the general norm on that? Link to comment https://forums.phpfreaks.com/topic/114181-solved-mysql-now-vs-php-date/ Share on other sites More sharing options...
DarkWater Posted July 10, 2008 Share Posted July 10, 2008 You'd probably want to create a DATETIME column in MySQL, use NOW(), and then DATE_FORMAT to pull out the date how you want it. Link to comment https://forums.phpfreaks.com/topic/114181-solved-mysql-now-vs-php-date/#findComment-587087 Share on other sites More sharing options...
PFMaBiSmAd Posted July 10, 2008 Share Posted July 10, 2008 When you can accomplish something in a query using mysql functions, it will save processing time over using php code to do the same task. Link to comment https://forums.phpfreaks.com/topic/114181-solved-mysql-now-vs-php-date/#findComment-587092 Share on other sites More sharing options...
Barand Posted July 10, 2008 Share Posted July 10, 2008 From a documentation point of view, using NOW() for current time, or CURDATE() for current date, tells anyone looking at you query code that the query is always based on the current time or date. If there is a '$date' variable in there it could be any date or time and they then have to refer to occurences in the code where the query is called to find that the current date/time is being passed to the query. Conversely, using NOW() or CURDATE() in a query that is always based on the current date/time saves you having to construct it in PHP before calling the query. Link to comment https://forums.phpfreaks.com/topic/114181-solved-mysql-now-vs-php-date/#findComment-587096 Share on other sites More sharing options...
Prodigal Son Posted July 11, 2008 Author Share Posted July 11, 2008 Thanks guy. I thought the opposite, I thought using NOW() was slower and uses more resources or something Link to comment https://forums.phpfreaks.com/topic/114181-solved-mysql-now-vs-php-date/#findComment-587164 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.