do the following in a endless loop due to the fact that we have no cronjob or anything similar to start a job automatically */ while (true) { /* get Timestamp for today */ $time = date('H:i', time()); // 10:00 $today = date('d-m-Y ', time()); /** only send a message with new daily texts if time is 08 o clock **/ if (strcmp($time, "08:00") == 0) { $dailyTexts = new DailyTexts($today); $msg = "Losung fuer den " . $today . "\n" . "Watchword: " . $dailyTexts->getWatchword() . "\n" . "Doctrine: " . $dailyTexts->getDoctrine() . "\n"; echo $msg; /** Sending message to the group with the daily dext: Where $gId is the group id. **/ $w->sendMessage($gId, $msg); //sleep for 23 hours //sleep(23*60*60); } sleep(59); $w->sendPing(); }
<?php require_once "DailyTexts.class.php"; date_default_timezone_set('Europe/Berlin'); ini_set('date.timezone', 'UTC'); $today = date('d.m.Y ', time()); $dailyTexts = new DailyTexts($today); echo "Losung fuer den: " . $today . "\n"; echo "Losungstext:\t" . $dailyTexts->getWatchword() . "\n"; echo "Lehrtext:\t" . $dailyTexts->getDoctrine() . "\n";