homepage Welcome to WebmasterWorld Guest from 54.83.133.189
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Accredited PayPal World Seller

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
New to PHP. Need a little help.
tmrchris




msg:4470470
 2:58 pm on Jun 28, 2012 (gmt 0)

I have a code which was written by a friend of mine for the radio station I work at. It displays the on air now info of the current show and additionally 'next' etc.

<?php
function getdetails(){
date_default_timezone_set ("GMT +5");


$d = date("D");
$t = date("H", time());
switch ($d)
{

/////////////////////////////////Monday////////////////////////
case Mon:

//////////////////////////up to 1am////////////
if ($t < 1) {

$title = "Late Night Love Songs";


$next = "Non Stop Pop at 1am";
$image = "<img src=\"images/love.png\"></img>";
$player = "<img src=\"images/nonstopcube.png\"></img>";
$onairnow = "The best chilled out songs ever made - back to back to end the day...";
}
////////////////////////////////////////////////

///////////////////////////////////////////////
elseif ($t < 12) {

$title = "Non Stop Pop";

$image = "<img src=\"images/nonstop.png\"></img>";
$player = "<img src=\"images/nonstopcube.png\"></img>";
$next = "Non Stop Pop";
$onairnow = "All your favourite pop tunes non-stop!";
}
////////////////////////////////////////////////

///////////////////////////////////////////////
elseif ($t < 19) {

$title = "Non Stop Pop";

$image = "<img src=\"images/nonstop.png\"></img>";
$player = "<img src=\"images/nonstopcube.png\"></img>";
$next = "Club Mix at 7pm";
$onairnow = "All your favourite pop tunes non-stop!";
}
////////////////////////////////////////////////

///////////////////////////////////////////////
elseif ($t < 22) {

$title = "Club Mix";

$image = "<img src=\"images/club.png\"></img>";
$next = "Late Night Love Songs at 10pm";
$onairnow = "The biggest dance floorfillers of all time";
}
////////////////////////////////////////////////


////////////10pm - 12am//////////////////////
else {

$title = "Late Night Love Songs";


$next = "Non Stop Pop at 1am";
$image = "<img src=\"images/love.png\"></img>";
$player = "<img src=\"images/nonstopcube.png\"></img>";
$onairnow = "The best chilled out songs ever made - back to back to end the day...";
}
////////////////////////////////////////////
break;


I now want the code to show up at xx:45 instead of xx:00. Looking at PHP: date [php.net] it says i=minutes. I've tried changing the code to H:i and then creating $t < 22 $i < 45 for example but that doesn't work.

How do I go about doing this? Many thanks for any help given. I'm trying to learn this by the way and have been doing my own research hence how I got here.

 

StoutFiles




msg:4470477
 3:21 pm on Jun 28, 2012 (gmt 0)

$t = date("Gi", time());

if ($t < 145)

elseif ($t < 1245)

...and so on. If you would like to learn more about the date function, I would look here.

[php.net...]

tmrchris




msg:4470483
 3:31 pm on Jun 28, 2012 (gmt 0)

Thanks for your help. As this is in 24 hours, what would I put for the time of 12.45am? Is it 0045 or 2445?

I was looking at that exact php page before posting :)

StoutFiles




msg:4470488
 3:47 pm on Jun 28, 2012 (gmt 0)

045. Or just 45. You will never see an hour of 24, it goes back to 0 after 23.

I suggest testing it yourself, changing the value of $t manually.

//$t = date("Gi", time());
$t = "045";

tmrchris




msg:4470504
 4:08 pm on Jun 28, 2012 (gmt 0)

Thanks very much for your help. This has been bugging me for a while now.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved