【问题标题】:finding weekday with php getdate() function使用 php getdate() 函数查找工作日
【发布时间】:2011-08-08 16:43:41
【问题描述】:

我正在尝试在 php 中构建一个函数,它需要用户输入日期,该日期可以是过去 20 年内的任何日期。我尝试使用 php 中的 getdate() 函数在星期几返回给他们。 这是我所拥有的不起作用的东西。

$date="8/4/2010";//user input
$dateget=getdate($date);
echo $dateget; // i want an output like "monday" or "saturday" 

当我运行这段代码时,我得到了这个错误

A non well formed numeric value encountered (on the $dateget=getdate($date) line)

谢谢

【问题讨论】:

    标签: php date weekday getdate


    【解决方案1】:

    您需要getdate function 的时间戳。所以也许 strtotime 函数可以提供帮助。

    $date="8/4/2010";//user input
    $dateget=getdate(strtotime($date));
    echo $dateget['weekday'];
    

    【讨论】:

      猜你喜欢
      • 2013-03-22
      • 1970-01-01
      • 1970-01-01
      • 2018-03-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-27
      • 1970-01-01
      相关资源
      最近更新 更多