Re: MySQL datetime extraction
| From: | John W. Holmes | Date: | Sat, 19 Jul 2003 18:28:00 +0000 |
| Subject: | Re: MySQL datetime extraction | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-155907@lists.php.net to get a copy of this message | ||
Yasir Malik wrote:
Given a date in MySQL datetime format, how do I extract the elements? That is get the month, day, year, hour, ...You could do it in the query using DATE_FORMAT(), MONTH(), YEAR(), etc. You can do it in PHP by sending the MySQL timestamp through strtotime() and then using date() to extract each component. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ PHP|Architect: A magazine for PHP Professionals – www.phparch.com