douxian3170 2014-09-14 17:41
浏览 61
已采纳

从时间戳PHP获取星期几

i am trying to get the day of week from a timestamp:

an example of the timestamp could be:

2014-09-14 18:28:11

I have tried with the following code:

$date = date("D", strtotime($activity[$i]['timestamp']));

However the result i get here is:

Thu

which should have been sunday?

Also is it possible to get it as a full discription instead of a short version of the day name?

  • 写回答

1条回答 默认 最新

  • drwpbrv668670 2014-09-14 18:16
    关注

    Answer to part two of the question is that you can just use l (lowercase 'L') and it'll output Sunday instead of Sun.

    $date = date("l", strtotime($activity[$i]['timestamp']));
    

    As for the first part, it probably output Thursday, 1 January 1970 because it received an error instead of an actual date as argument to strtotime.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?