dqd22496 2019-04-01 02:13
浏览 122

“没有找到”班级'日期“。 在php和js上使用日期,getDate(),setDate()

I'm trying to implement some validations regarding the date of some db elements but the function date() doesn't seem to work at all.

An uncaught Exception was encountered

Type: Error

Message: Class 'date' not found

Filename: BlaBlaBla

$today = new date();
    $today.setDate($today.getDate()-5);
    foreach ($query as $item)
    {
        if ($item->startDateSP.getDate()>=$today.getDate())
            {
                $final.push($key);
            }
    }

The order or logic of that code is not important. The thing is that none of the date-related functions are recognized and an error shows up. I just want to know if there's a way to make those dates work

</div>
  • 写回答

1条回答 默认 最新

  • dongluobei9359 2019-04-01 02:16
    关注

    You have to capitalize Date(), that's all:

    let today = new Date();
    today.setDate(today.getDate() - 5);
    console.log(today);

    </div>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分