logo change by time of day

Started on the old forum in May 2009 · view the original in the archive · old links redirect here

7 replies · 1,541 views · started 17 years ago · 1 min read

6 participants
valentinbr Junior · 26 posts #1
////////////////////////////////in core
function logo($fus)
{
  $lo = time() + ($fus * 60 * 60);
  $ora =date("G", $xp);

if ($ora <= 4) {
$logo="<img src=\"logo/nbuna.png\" alt=\"x\"/>" ;
}else if ($ora <= 10) { 
$logo="<img src=\"logo/neatza.png\" alt=\"x\"/>" ; 
}else if ($ora <= 16) {
$logo="<img src=\"logo/ziua.png\" alt=\"x\"/>" ; 
}else if ($ora <= 22) { 
$logo="<img src=\"logo/seara.png\" alt=\"x\"/>" ;
}

   return $logo;
}
///////in index
echo "".logo("0")."<br/>";
Create 4 logos depending on time of day
i0nutzxp Developer · 150 posts #2

Updated ///////bcoz that was the beta

function xplogo($fus)
{
  $xp = time() + ($fus * 60 * 60);
  $ora =date("G", $xp);

if ($ora <= 6) {
$logo="<img src=\"logo/nbuna.png\" alt=\"x\"/>" ;
}else if ($ora <= 10) { 
$logo="<img src=\"logo/neatza.png\" alt=\"x\"/>" ; 
}else if ($ora <= 18) {
$logo="<img src=\"logo/ziua.png\" alt=\"x\"/>" ; 
}else if ($ora <= 22) { 
$logo="<img src=\"logo/seara.png\" alt=\"x\"/>" ;
}

   return $logo;
}

and who want logo like that pm me:)

<?php unlink('World/Europe/Romania.country'); ?>
Attachments: logo.rar
djlee Developer · 224 posts #3

simple but effective, just a bit of info though, when your working with stuff like this where your returning only a line or twoits a lot nicer to use the switch() statment than a big tree of IF's... switch does have a slight better performance in this scenario but nothing worth measuring, its simply for code readability and good design... plus its the perfect opportunity for people to learn how switches work if they arent familiar with um 🙂

on the whole though its a nice little addon, just a note to anyone looking for something slightly different

if you want just morning and afternoon, just use the am/pm date param and name your logos am.png/pm.png and theres no need for the if's or a switch or if you have one per hour you could name them 1.png/2.png/3.png ect and call them directly without the conditional tree

just mentioning it as i saw two people recently that used both those things and used a conditional tree for which its not needed 🙂

i0nutzxp Developer · 150 posts #4

djlee wrote: simple but effective, just a bit of info though, when your working with stuff like this where your returning only a line or twoits a lot nicer to use the switch() statment than a big tree of IF's... switch does have a slight better performance in this scenario but nothing worth measuring, its simply for code readability and good design... plus its the perfect opportunity for people to learn how switches work if they arent familiar with um 🙂

on the whole though its a nice little addon, just a note to anyone looking for something slightly different

if you want just morning and afternoon, just use the am/pm date param and name your logos am.png/pm.png and theres no need for the if's or a switch or if you have one per hour you could name them 1.png/2.png/3.png ect and call them directly without the conditional tree

just mentioning it as i saw two people recently that used both those things and used a conditional tree for which its not needed :)

thx for the info mane:D

<?php unlink('World/Europe/Romania.country'); ?>
Guest #6

thanks mate

shad0w Developer · 119 posts #7

Is not very hard to code a script like that. Is it? ... 10 minutes of hard work 😀... Anyway ... Nice share.

whatmp3.name - search mp3 on mobile

Write your reply now; next you create a free account (or sign in) and it is posted right away. Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close