- var_dump: documentation ( source)
- time: documentation ( source)
- date_default_timezone_set: documentation ( source)
- strtotime: documentation ( source)
- gmdate: documentation ( source)
<?php
namespace DrummondCentral\Bender\Command;
class Command {}
namespace Commands;
use DrummondCentral\Bender\Command\Command;
class HometimeCommand extends Command
{
public static function getCommand()
{
return 'hometime';
}
public static function getDescription()
{
return 'Displays the number of hours and minutes until home time.';
}
public function handle($message)
{
date_default_timezone_set('Europe/London');
$workend = strtotime('17:30');
$diff = $workend - time();
$hometime = gmdate("H:i:s", $diff);
if (time() === $workend) {
return 'It\'s home time! Rejoice!';
}
return "Home time is in " . $hometime . ".";
}
}
$command = new HometimeCommand();
var_dump($command->handle(''));