php get time isn't working correcly

hello
so i have php code like this

<?php $time_start = time(); if (isset($_POST['get'])) { $time_end = time(); } ?>

everything is working but i wan my code to get time when page loads
and when isset $POST then it gets time_end which is time when button were pressed, but my problem is that $time_start and $time_end are the same

PHP runs the code on every request, so this code will set time_start when loading the page, and then set it again when you post to the file. If you store the start time in ie the session then you can use that time to compare with the current time

Sponsor our Newsletter | Privacy Policy | Terms of Service