I have a table that should be truncated every 12 hours. I created a header with a javascript function that display the current time for the operator and it refreshed every second. I tried to call a php function from that timer on a specific time that will truncate a table. But the problem is, when the application started it call that function immediately and it truncate the table.
script>
window.onload = function(){
function startTime() {
var today = new Date();
var h = today.getHours();
var m = today.getMinutes();
var s = today.getSeconds();
if (h==6 && m==0 && s=1)
{
var phpret="<?php trunctTable() ?>;";
}
document.getElementById('my_time').innerHTML = today.toLocaleString();
var t = setTimeout(startTime, 1000);
}
startTime();
}
/script>
< ? php
function trunctTable() {
sc_exec_sql(“truncate table mytable”);
}
?>