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 | 9 Comments »

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

  1. discover this Says:
    October 4th, 2021 at 19:16

    … [Trackback]

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

  2. https://tontonmania123.com/ Says:
    November 16th, 2021 at 11:12

    … [Trackback]

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

  3. sbo Says:
    November 18th, 2021 at 20:20

    … [Trackback]

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

  4. kardinal stick Says:
    November 19th, 2021 at 20:15

    … [Trackback]

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

  5. 스포츠중계 Says:
    December 13th, 2021 at 18:34

    … [Trackback]

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

  6. Digital Transformation Strategy Says:
    December 15th, 2021 at 05:19

    … [Trackback]

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

  7. Phygital Retailing Strategies Says:
    December 20th, 2021 at 15:16

    … [Trackback]

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

  8. car dealership surveillance Says:
    January 3rd, 2022 at 20:13

    … [Trackback]

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

  9. wow slot Says:
    January 10th, 2022 at 18:58

    … [Trackback]

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

Comments