0

I want to reset my mysql table column every day (12 AM), week and month. I have just single row in my mysql table.

$current_date = date_default_timezone_set('Asia/Kolkata');
$current_date = date('H:i:s');
$timestamp = strtotime($current_date);
$gettime = date("h:i A", $timestamp);
if($gettime == "11:59 PM")
{
    update mysql table column to 0 ???          
}

I have tried this above code for reset table column every day. But, I'm not sure. Is this the right way to reset column? If it is correct then How do I do this for week and month?

Karuppiah RK
  • 3,894
  • 9
  • 40
  • 80
  • See this Q&A http://stackoverflow.com/q/13968494/ and use cron. – Funk Forty Niner Sep 30 '14 at 07:30
  • 1
    Wow that's an incredibly long piece of code to get current time. And that logic will need to run conitnously always which is wrong. This is the job of cron scheduler that runs at the specific time and updates your table. – Hanky Panky Sep 30 '14 at 07:31
  • You should use cron job to update table values – TBI Sep 30 '14 at 07:33

1 Answers1

0

What about use crontab?

Make a shell script with mysql command line tool.

Youngsik Oh
  • 54
  • 1
  • 4