Created
September 21, 2012 09:39
-
-
Save hemache/3760628 to your computer and use it in GitHub Desktop.
counttimerdown
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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