Пример #1
0
 public static function getOpenStatus($opening_hours)
 {
     // Returnerer om ikke åpningstider er lagret
     if ($opening_hours == null) {
         return null;
     }
     // Konverterer dagen i dag til minutter
     $dateAndTime = new dateAndTime();
     $hour_now = $dateAndTime->getHour();
     $min_now = $dateAndTime->getMinute();
     $time_now = 1 * 1440 + 60 * $hour_now + $min_now;
     // Finner åpningstider for i dag
     $weekday_today = strtolower(date("l"));
     if (!isset($opening_hours[$weekday_today])) {
         return null;
     }
     $open_times_today = $opening_hours[$weekday_today];
     $openTodayArray = explode(':', $open_times_today["open"]);
     $closeTodayArray = explode(':', $open_times_today["close"]);
     $openTodayArrayMin = array("open" => "", "close" => "");
     // 1 er i dag, 2 er i morgen. Dette er for at åpningstider skal beregnes riktig
     // også for bedrifter som stenger etter 00:00.
     if ($open_times_today["close"] < $open_times_today["open"]) {
         $openTodayArrayMin["open"] = 1 * 1440 + 60 * $openTodayArray[0] + $openTodayArray[1];
         $openTodayArrayMin["close"] = 2 * 1440 + 60 * $closeTodayArray[0] + $closeTodayArray[1];
     } else {
         $openTodayArrayMin["open"] = 1 * 1440 + 60 * $openTodayArray[0] + $openTodayArray[1];
         $openTodayArrayMin["close"] = 1 * 1440 + 60 * $closeTodayArray[0] + $closeTodayArray[1];
     }
     // Returnerer true/false avhengig av om bedriften er åpen eller ikke
     if ($time_now >= $openTodayArrayMin["open"] && $time_now < $openTodayArrayMin["close"]) {
         return true;
     } else {
         return false;
     }
 }
Пример #2
0
	<div id="footer">
		<?php 
$dateAndTime = new dateAndTime();
echo "IP-adresse: <b>" . $ip . "</b>";
echo "<br />";
echo "Dato: <b>" . $dateAndTime->getDate() . "</b>";
echo "<br />";
echo "Tid: <b>" . $dateAndTime->getTime() . "</b>";
?>
	</div>
</body>
</html>
Пример #3
0
 public static function saveSearchAddress($ip, $street_address, $postal_code)
 {
     global $db;
     $dateAndTime = new dateAndTime();
     $date = $dateAndTime->getDate();
     $time = $dateAndTime->getTime();
     // SQL-spørring for å lagre utførte søk
     $sql = "INSERT INTO search_addresses (ip, date, time, street_address, postal_code)\n\t\t\tVALUES ('" . $ip . "', '" . $date . "', '" . $time . "', '" . $street_address . "', '" . $postal_code . "');";
     $result = $db->query($sql);
 }