Re: MySQL Date insert

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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





--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux