I need to query MySQL for the current date (from PHP) in YYYY-MM-DD
format... anyone?
Asked
Active
Viewed 8.3k times
25

Mikey1980
- 971
- 4
- 15
- 24
-
1*(reference)* Date and Time Functions in MySql: http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_curdate and PHP Date Function: http://de.php.net/manual/en/function.date.php – Gordon May 13 '10 at 18:12
4 Answers
56
-
What if for selected timezone like Philippines, how do I implement that one? – RoCkDevstack Jun 23 '16 at 11:29
0
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
- 1,619
- 11
- 12