0

Im trying to store the datetime when a link is clicked so that later when a form is filled in, the variable is passed to a crud.php file to update information along with the time the link was clicked. Everything is working except I cannot seem to just get the datetime of the link being pressed. I've tried putting it into a for the on click and i feel it should be simple but I cannot seem to get it!

Example Link Code

<a href="http://examplelink/index.php" target="_blank" rel="noopener noreferrer" onclick="myFunction();">
<h2>Webpage One</h2>
<p>This link will open the website in a new tab. Please ensure you close this website, and not the survey website once you no longer require it.</p>
</a>

Example Script on the same .php file

<script>
function myFunction() {
  <?php
  if ($startdate == null) {
    $startdate=date('Y-m-d H:i:s');}
    ?>
}
</script>
  • See also https://stackoverflow.com/questions/23740548/how-do-i-pass-variables-and-data-from-php-to-javascript – Syscall Jan 25 '22 at 17:32

0 Answers0