开发者

MKTIME, PHP date/timestamp YYYY-MM-DD

开发者 https://www.devze.com 2022-12-30 09:03 出处:网络
I n开发者_JAVA百科eed to query MySQL for the current date (from PHP) in YYYY-MM-DD format... anyone?MySQL curdate:

I n开发者_JAVA百科eed to query MySQL for the current date (from PHP) in YYYY-MM-DD format... anyone?


MySQL curdate:

You can do in query:

select curdate()

PHP date

echo date('Y-m-d');

If you want to pass your own date format:

echo date('Y-m-d', strtotime($your_date));


date("Y-m-d") should give you the current date in that format.


SELECT CURDATE();


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

0

精彩评论

暂无评论...
验证码 换一张
取 消