I have an working javascript code that i use on an webpage to set text of an button. The text of the button show the time in 24 hour format with added 1 hour and 30 minutes rounded of to nearest 5 minutes. As i need to use the resulting time in an php code snippet on button click i need to convert my code to php syntax to get the same result.
As example if time now is 15:17 the result should be 16:50
<SCRIPT>
var today = new Date();
today.setHours(today.getHours() + 1);
today.setMinutes(today.getMinutes() + 30);
var coeff = 1000 * 60 * 5;
var date = "09:07:00"; //or use any other date
var rounded = new Date(Math.round(today.getTime() / coeff) * coeff)
var tid_1hour30min_from_now = rounded.toLocaleTimeString([], {hour: '2-digit', minute:'2-digit'});
var tid_hour = rounded.getHours();
var tid_minutes = rounded.getMinutes();
var ater = "Åter"
var result1hour30minfromnow = ater +" "+ tid_1hour_from_now
</SCRIPT>
So i would like to do the same but in php.
Been trying with simular code to this:
$startTime = date("Y-m-d H:i:s");
$cenvertedTime = date('Y-m-d H:i:s',strtotime('+1,5
hour',strtotime($startTime)));
$current_time = strtotime($cenvertedTime);
$frac = 900;
$r = $current_time % $frac;
$new_time = $current_time + ($frac-$r);
$new_date = date('Y-m-d g:i:s A', $new_time);
But this doesn't turn out well, i newer get the same time in both script above. How can i translate the javascript as close as possible to php?
/ Kristian