开发者

Php date() giving the wrong time after parsing

This is confusing as hell, here's the php I'm using:

<?php echo date('H:i D j, F',$j->date); ?>

This is what it gives me:

01:33 Thu 1, January

Which seems fine, until you look at the actual time that is being given ($j->date provides):

2010-06-12 21:12:23

W开发者_如何学Chy is it giving me a January and what am I doing wrong?


$j->date must provide date() with a standard unix timestamp. take a look at the manual. You might want to pass it through the strtotime() function first.

<?php echo date('H:i D j, F', strtotime($j->date)); ?>

$j->date output must be a US English date format.


Try this:

<?php echo date('H:i D j, F', strtotime($j->date)); ?>

The date() function only takes a timestamp, not a time string which you are trying to provide it. The strtotime() function will convert it for you before sending it to date().

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜