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.

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

报告相同问题?

悬赏问题

  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 有没有帮写代码做实验仿真的
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥30 vmware exsi重置后登不上
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?
  • ¥15 电磁场的matlab仿真