开发者

PHP date() formatting

I'm trying to format my date like YYYY-MM-DD.

I'm doing this:

 $dateAdded = date(Y-m-d);

So开发者_StackOverflow社区 for today, it should say 2011-05-07, but it keeps returning 0000-00-00. Any help?


$dateAdded = date("Y-m-d");

Its string, you forgot the ".


You should use quotes because Y-m-d is a string:

$dateAdded = date("Y-m-d");


You need quotes around the date format string..

$dateAdded = date('Y-m-d');


$dateAdded = date("Y-m-d");

The date function requires a string formatter. (Check the manual for more formatting constants.)

You can also use an optional timestamp if you want to format a date that is not mktime():

$dateAdded = date("Y-m-d", $myTimestamp);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜