I need to query MySQL for the current date (from PHP) in YYYY-MM-DD
format... anyone?
views:
199answers:
4
+1
A:
MySQL:
You can do in query:
select curdate()
PHP
echo date('Y-m-d');
If you want to pass your own date format:
echo date('Y-m-d', strtotime($your_date));
Sarfraz
2010-05-13 18:02:08
A:
The function I think you are looking for is
$datetime = strtotime($MySQLDateResponse);
$MySQLDatResponse being the date you get back from MySQL. This will give you a PHP time stamp. You can then convert that timestamp into any date format you want. For the one you listed it's
date("Y-m-d", $datetime);
Hope that helps
Joe Mills
2010-05-13 18:04:04