Skip to content

Instantly share code, notes, and snippets.

@hemache
Created September 21, 2012 09:39
Show Gist options
  • Select an option

  • Save hemache/3760628 to your computer and use it in GitHub Desktop.

Select an option

Save hemache/3760628 to your computer and use it in GitHub Desktop.
counttimerdown
<?php
mysql_query('INSERT INTO mytable (counttimer)
VALUES ("01:11:11")');
$res = mysql_query('SELECT * FROM mytable LIMIT 1');
$row = mysql_fetch_row($res);
// 1 يمكن استعمال time_sleep_until() بدل حلقة التكرار
// time_sleep_until( strtotime($row[0]) );
// 2 تحويل التاريخ الى قيمة عددية timestamp
// عبر انقاص قيمة timestamp الحالية من القيمة المجلوبة من قاعدة البيانات
$timestamp = strtotime($row[0]) - time();
foreach(range(0, $timestamp) as $i)
{
sleep(1);
$timestamp -= 1;
}
// احفظ التوقيت الحالي
$currentTime = strftime('%T');
mysql_query("UPDATE mytable SET counttimer = '{$currentTime}' LIMIT 1");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment