You can not!
First, since this is for a class, you must understand what the three parts are. The server-side, client-side and Javascript are. Here are the details.
PHP is SERVER-SIDE only! It only runs on a server, never inside a browser. Therefore, it can not alter anything that is already loaded into the browser. That is why PHP is secure and usually used to load data or client-side display info into a browser. Once posted to the browser, the system becomes CLIENT-SIDE only. Meaning that it runs on your local computer. PHP never gets there. You will never see any PHP code in the source of a browser page, well, unless it is displayed as text to explain code like on this page you are reading. Javascript or JQuery are CLIENT-SIDE programming code systems that run inside various browsers. They can alter things on the live page in a programmed manner.
Now, with that explained, you could create a button which is an HTML input tag and have it go to a Javascript routine. To do that, when you create the button, make it point to a javascript routine. In that routine, check if the button is outside the timeframe. Similar to how you did it in your example. But, you will need to alter the code to keep the time the page was posted or it will not work.
You could use AJAX to call a PHP file and have it checked a saved time frame, but, that is complicated. You can just add a PHP line in the system to set the time and then compare against it. Or you can use timeout() functions to disable things as needed. You can set your button to call a JS routine. Then set a timeout function for like 3000 milliseconds. After the 3000 milliseconds, a variable can be changed and depending on that results, either allow the button or just throw out an alert saying too late.
Not sure if that makes sense to you. Give it a try and post what you come up with… Good luck.