Compdigitec Labs

« | Home | »

Simple timer script for command-line PHP

By admin | November 12, 2008

Are you looking for a simple timer script written in command-line PHP? If so, here is one pre-written (released under the GPL v2 or later):

<?php
define("endl","\n");
// Timer script
if($argv[1] == "") {
 	echo "Usage: ".$argv[0]." minutes".endl;
 	die();
}
$dtime = strtotime("+".$argv[1]." minute");

while(true) {
 	echo "Enter to check time: ";
 	$tt = fgets(STDIN);
 	$i = date("i",$dtime-time());
 	$s = date("s",$dtime-time());
 	echo "$i minutes, $s seconds".endl;
}
?>

Usage: When launching use first parameter as number of minutes to count (0-59 min). Press enter to check the time.

If you found this script useful or helpful, please help Compdigitec by spreading the word. Don’t forget to subscribe to Compdigitec Labs for more interesting articles!

If you found this article helpful or interesting, please help Compdigitec spread the word. Don’t forget to subscribe to Compdigitec Labs for more useful and interesting articles!

Topics: PHP | 10 Comments »

10 Responses to “Simple timer script for command-line PHP”

  1. zxz99 Says:
    November 10th, 2024 at 19:05

    … [Trackback]

    […] Find More on that Topic: compdigitec.com/labs/2008/11/12/simple-timer-script-for-command-line-php/ […]

  2. jaxx download Says:
    November 14th, 2024 at 04:27

    … [Trackback]

    […] Read More on that Topic: compdigitec.com/labs/2008/11/12/simple-timer-script-for-command-line-php/ […]

  3. PGSLOT true wallet แตกง่ายไม่ล็อตยูส Says:
    November 18th, 2024 at 01:14

    … [Trackback]

    […] Find More to that Topic: compdigitec.com/labs/2008/11/12/simple-timer-script-for-command-line-php/ […]

  4. link Says:
    November 27th, 2024 at 11:29

    … [Trackback]

    […] Read More to that Topic: compdigitec.com/labs/2008/11/12/simple-timer-script-for-command-line-php/ […]

  5. live shows Says:
    December 7th, 2024 at 02:36

    … [Trackback]

    […] Find More on that Topic: compdigitec.com/labs/2008/11/12/simple-timer-script-for-command-line-php/ […]

  6. รับสร้างบ้าน Says:
    December 23rd, 2024 at 18:28

    … [Trackback]

    […] Here you will find 29530 more Info on that Topic: compdigitec.com/labs/2008/11/12/simple-timer-script-for-command-line-php/ […]

  7. sci diyalaa Says:
    January 2nd, 2025 at 22:46

    … [Trackback]

    […] Here you can find 24443 more Info to that Topic: compdigitec.com/labs/2008/11/12/simple-timer-script-for-command-line-php/ […]

  8. lost mary os5000 Says:
    January 4th, 2025 at 00:29

    … [Trackback]

    […] Read More Info here on that Topic: compdigitec.com/labs/2008/11/12/simple-timer-script-for-command-line-php/ […]

  9. เฟอร์นิเจอร์สไตล์มินิมอล Says:
    January 5th, 2025 at 00:50

    … [Trackback]

    […] Info to that Topic: compdigitec.com/labs/2008/11/12/simple-timer-script-for-command-line-php/ […]

  10. Earn cash fast Says:
    January 5th, 2025 at 06:54

    … [Trackback]

    […] Here you can find 26119 additional Information to that Topic: compdigitec.com/labs/2008/11/12/simple-timer-script-for-command-line-php/ […]

Comments