0

Excuse me, can you help to edit this code, it basically reads the current user time zone (javascript), I need this time zone to be stored in php, so I can add a number of minutes to five me a new timing.

<html>
<script type="text/javascript">

var currentTime = new Date();
var hours = currentTime.getHours();
var minutes = currentTime.getMinutes();

if (minutes < 10) {
    minutes = "0" + minutes;
}



</script>

<?php
$getting_time = "<script> document.write(hours, minutes); </script>";
$endTime1 = strtotime("+10 minutes", strtotime($getting_time));
echo date('h:i A', $endTime1);
echo "<br>";

?>

</html>

For more clarification:

  • If the client's timing now is 15:30
  • I want to add to this timing 120 minutes
  • So, the final timing will be 17:30

Thank you

I am not familiar at all with JavaScript, I visited the suggested Q, but I couldn't solve my issue.

i8a6ari
  • 3
  • 2
  • If you're just getting started with PHP and want to build applications, I'd strongly recommend looking at various [development frameworks](https://www.cloudways.com/blog/best-php-frameworks/) to see if you can find one that fits your style and needs. They come in various flavours from lightweight like [Fat-Free Framework](https://fatfreeframework.com/) to far more comprehensive like [Laravel](https://laravel.com/). These give you concrete examples to work from and guidance on how to write your code and organize your project's files. – tadman May 30 '21 at 15:38
  • Answers in the suggested post tell you, that you can't do what you want. Your PHP code is executed on your server, it creates a string representing HTML document. When this string is received on a browser, the browser will parse the string to a live document. There's no connection between your PHP code and the parsed HTML document in the browser. – Teemu May 30 '21 at 16:38
  • It's notable, that you can add content to a page with JS too. In your case, you don't need PHP at all. See https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Client-side_web_APIs/Manipulating_documents – Teemu May 30 '21 at 16:49

0 Answers0