Jough Jeaux wrote:
Greetings all, I'm working on a message-board-type application that will use time stamps to sort part of the messages. I was wondering what everyone's favorite way to transfer dates between PHP and MySQL was?

Since you'll be doing most of the sorting (if not all) actually within your queries, it'd be best to store MySQL timestamps in a TIMESTAMP or DATETIME column. There are a wealth of Date and Time functions in MySQL that allow you to easily SELECT out what you want. You can use the DATE_FORMAT() function within your queries to format the timestamp to your liking.


That being said, your other option is to use Unix timestamps in an INT column. This is what PHP uses, so it'd be compatible with the PHP date and time functions. You'd still be able to use the MySQL functions, except you'd first have to use FROM_UNIXTIME() on everything to convert it to a MySQL timestamp.

--
---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com

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



Reply via email to