Problem with $time variable

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
polosport6699
Forum Commoner
Posts: 35
Joined: Wed Jun 11, 2003 3:19 pm

Problem with $time variable

Post by polosport6699 »

I don’t understand it but before a certain time in the morning the listen live box and now on air script do not function

I wrote a test script and tried it on my personal server

http://www.amishmastercrafts.net/am1.php

It successfully echoed the $time variable because the server time is 7:15 so it selected from 7:00
When I use that same script on our webserver

http://ubb.avemariaradio.net/amrwdeonet ... ve/am1.php

It does not echo anything…….This problem is very confusing to me because after some time during the day it just begins to work…

Code: Select all

$date = date("g:i:sa",strtotime("now"));

if(($date >= "6:59:02am" && $date <= "7:29:01am" )){ $time="7:00am"; }
elseif (($date >= "9:59:02am" && $date <= "10:29:01am" )){ $time="10:00am"; }
echo "$date";
echo "<br>";
echo "Working.....";
echo $time;
That’s my code I’m using to test if the selection is working…..
User avatar
mcsleazycrisps
Forum Newbie
Posts: 6
Joined: Mon Aug 25, 2003 7:12 am
Location: UK

Post by mcsleazycrisps »

surely using less than / greater than on a string won't work

the "am" and ":" would mean that $date is a string, and checking if a string is greater than something won't work. try formatting the date without the : and the AM, and PM to keep it as a number

Code: Select all

<?php
$date = date("Gis",strtotime("now"));

if (($date >= "65902" && $date <= "72901")){$time="7:00am";}
..
..
Post Reply