简体   繁体   中英

"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.

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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