RE: [PHP-DB] inserting dates
| From: | John W. Holmes | Date: | Thu, 23 Jan 2003 00:24:50 +0000 |
| Subject: | RE: [PHP-DB] inserting dates | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-25055@lists.php.net to get a copy of this message | ||
> check out DATE_FORMAT in the mysql manual. and acually you'll want
> year-month-day not year/month/day...if you're using the mysql defualt
> date.
Actually, you can use any delimiter with MySQL, so long as it's in year,
month, day order.
> DATE_FORMAT(NOW(), '%m/%d/%Y') ----- would return 01/22/2003
> When I insert a date into Mysql it has to be in year/month/day format
or
> else it wont go in right.
> how do I convert my date variable which is in month /day /year format
into
> year/month/day format?
Many ways. This question was just asked today, actually. Simple way is:
$part = explode("/",$your_date);
$mysql_date = $part[2] . $part[0] . $part[1];
for YYYYMMDD format, which is also valid. Adapt to your needs.
---John Holmes...