Jump to content

calculating if current time falls between a preset range?


Recommended Posts

<?php
if ($time>15:00:00||$time<3:00:00)
{echo " the time Range  is .....";}?>

 

hmm, that kinda is what i've got...what am I missing

 

<?
	$today = date('N');					

	$q = "SELECT * FROM hours WHERE day = $today";
	$result = mysql_query($q, $conn);
	$tmp = mysql_fetch_assoc($result);

	$o = $tmp['open'];
	$c = $tmp['close'];

		if ($now >= $o && $now <= $c ) { $status = "OPEN";}
		 else { $status = "CLOSED";}	
                        echo "$name is normally $status at this time!" 

?>	

<=  is bad syntax only used for OOP.

 

if its regular PHP programming you need

<?php
if ($now >$o||$now<$c) { $status = "OPEN";}
		 else { $status = "CLOSED";	
                        echo "$name is normally $status at this time!";} ?>

 

 

also paste the full code i have no idea where $now is defined or how it tells i its open or closed

<=  is bad syntax only used for OOP.

 

if its regular PHP programming you need

<?php
if ($now >$o||$now<$c) { $status = "OPEN";}
		 else { $status = "CLOSED";	
                        echo "$name is normally $status at this time!";} ?>

 

 

also paste the full code i have no idea where $now is defined or how it tells i its open or closed

good to know, thanks. will that work though, if the times are after midnight? 9PM to 3AM or something?

 

<?
date_default_timezone_set('America/Los_Angeles');
$now = date('H:i:s');

$today = date('N');					

$q = "SELECT * FROM hours WHERE day = $today";
$result = mysql_query($q, $conn);
$tmp = mysql_fetch_assoc($result);

//result is returned via MySQL in 24:00 datetime format

$o = $tmp['open'];

//result is returned via MySQL in 24:00 datetime format	
        $c = $tmp['close'];

	if ($now >= $o && $now <= $c ) { $status = "OPEN";}
	 else { $status = "CLOSED";}	
				echo "$name is normally $status at this time!" 

?>

 

 

<?php
date_default_timezone_set('America/Los_Angeles');
$now = date('H:i:s');

$today = date('N');					

$q = "SELECT * FROM hours WHERE day = $today";
$result = mysql_query($q, $conn);
$tmp = mysql_fetch_assoc($result);

//result is returned via MySQL in 24:00 datetime format

$o = $tmp['open'];

//result is returned via MySQL in 24:00 datetime format	
        $c = $tmp['close'];

	if ($now > $o || $now < $c ) { $status = "OPEN";}
	 else { $status = "CLOSED";}	
				echo "$name is normally $status at this time!" 

?>

 

yes this makes since but how does it know when closing or opening is? thats my point it wont work if  it doesnt know what the opening or closing times are.

<=  is bad syntax only used for OOP.

 

if its regular PHP programming you need

<?php
if ($now >$o||$now<$c) { $status = "OPEN";}
		 else { $status = "CLOSED";	
                        echo "$name is normally $status at this time!";} ?>

 

 

also paste the full code i have no idea where $now is defined or how it tells i its open or closed

<=  is bad syntax only used for OOP.

 

if its regular PHP programming you need

<?php
if ($now >$o||$now<$c) { $status = "OPEN";}
		 else { $status = "CLOSED";	
                        echo "$name is normally $status at this time!";} ?>

 

 

also paste the full code i have no idea where $now is defined or how it tells i its open or closed

good to know, thanks. will that work though, if the times are after midnight? 9PM to 3AM or something?

 

<?
date_default_timezone_set('America/Los_Angeles');
$now = date('H:i:s');

$today = date('N');					

$q = "SELECT * FROM hours WHERE day = $today";
$result = mysql_query($q, $conn);
$tmp = mysql_fetch_assoc($result);

//result is returned via MySQL in 24:00 datetime format

$o = $tmp['open'];

//result is returned via MySQL in 24:00 datetime format	
        $c = $tmp['close'];

	if ($now >= $o && $now <= $c ) { $status = "OPEN";}
	 else { $status = "CLOSED";}	
				echo "$name is normally $status at this time!" 

?>

LOL funny  ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.