PHP if Else - Please help 100NP's

Namecheap AuctionsNamecheap Auctions
Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
Watch

emadiba

VIP Member
Impact
3
Hi there Guys,

Im stuck on something very basic and actually feel quite embarrassed...lol

I need some help in what im doing wrong here.

<?php
$hour = $_GET['hours'];
$min = $_GET['mins'];
$sec = $_GET['secs'];
$time = '$hour:$min:$sec';

if($time >= 07:00:00 && <= 18:59:59){
$shift = Days;
}
else {
$shift = Nights;
}

?>

Basically what im trying to do is say that if the time is between 07:00:00 and 18:59:59 then Hold the term Days as a variable, otherwise hold the term Nights.

Can Someone Please help me out

:-/ :-/ :-/ :-/ :-/

Thanks.... 100NP's To The First Person that Helps me


:)
 
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
You just need to check $hour like you only want to test if hour is between 7 and 18 including.

Here the code.

Code:
<?php 
$hour = $_GET['hours'];
$min = $_GET['mins'];
$sec = $_GET['secs'];
$time = '$hour:$min:$sec';

if($hour >= 7 && $hour <= 18 ){
$shift = 'Days';
}
else {
$shift = 'Nights';
}

echo $shift;

?>
Hope that helps.
David.
 
0
Close
Thanks that did help,

NP's Sent

:)

Silly Mistake wasnt it....lol
 
1
Close
Donation greatly appreciated Clayton.

Thanks,
David.
 
0
Close
Just a small note since I see you're in to $_GET, etc.: If register_globals is on, you won't need to use $_GET or $HTTP_GET_VARS. If I type:

somescript.php?blah=blah02

and register_globals is on, $blah would contain "blah02" (without the quotes)
 
0
Close
just because that works EKukiela101 does not mean it should be used.

Register globals is a bad thing and should be turned off wherever possible
 
0
Close
0
Close
It's a security risk to turn register_globals on, and php recommends that register_globals should be set to off always. I believe most web hosts do not have this option turned on.
 
0
Close
Hi,

Just asking why not use the strftime() function easier to deal with and program.
 
0
Close
use the strftime() function like strftime("%c %p");
the %c tell you the time and date and the %p tell you the am pm bit,
you could also use %X instead of the %c.

Hope this has been helpful.............
 
0
Close
DomainEasy: white label portfolios are live. Enable yours.

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Switch between accounts
You can now stay logged in to more than one NamePros account in the same browser. Click your avatar, then "Accounts in this browser", to...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back