Re: MySQL Date insert

From: Date: Sun, 10 Aug 2003 09:06:03 +0000
Subject: Re: MySQL Date insert
References: 1 2  Groups: php.db 
Request: Send a blank email to php-db+get-29797@lists.php.net to get a copy of this message
Budelak wrote:
This is how I implemented a similar though not exactly the same problem: $tempdate = gmdate("d-m-Y"); $insertSQL = sprintf("INSERT INTO gennews (newsdate, newsheadline, country, newsfull) VALUES ($tempdate, %s, %s, %s); So, you only have to change the format of the gmdate what you want.
d-m-Y is not the MySQL format for a date, though, so that means you're saving the date in a VARCHAR or CHAR column. You lose the benifits of all the date and time functions built into MySQL when you do that. Not a good method... either store the dates as Unix timestamps or MySQL timestamps. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ PHP|Architect: A magazine for PHP Professionals – www.phparch.com

« previous php.db (#29797) next »