简体   繁体   English

“未找到‘日期’类”。 在 php 和 js 上处理日期、getDate()、setDate()

[英]"Class 'date' not found". Working with dates, getDate(), setDate() on php and js

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.我正在尝试对某些 db 元素的日期进行一些验证,但函数 date() 似乎根本不起作用。

An uncaught Exception was encountered遇到未捕获的异常

Type: Error类型:错误

Message: Class 'date' not found消息:找不到“日期”类

Filename: BlaBlaBla文件名: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我只想知道是否有办法让这些日期生效

You have to capitalize Date() , that's all:你必须大写Date() ,就是这样:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM