“没有找到”班级'日期“。 在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>

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

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

</div>