- This topic is empty.
-
AuthorPosts
-
April 26, 2010 at 4:04 am #28841ploughansenMember
I am trying to insert an image and some text at different times of the day.
Example:
"image1.png" + "Lorem ipsum" from 12pm to 8am
"image2.png" + "dolor sit amet" from 8am to 1pm
"image3.png" + "Pellentesque habitant" from 1pm to 4pm
"image1.png" + "Lorem ipsum" from 4pm to 12pmDoes anyone know of a way to do this?
April 26, 2010 at 5:02 am #74702Rob MacKayParticipantyou could do something simple like this:
Code:“image1.png”, “txt” => “Lorem ipsum”);
break;
case 09:
case 10:
case 11:
case 12:
case 13:
$dets = array(“img” => “image2.png”, “txt” => “dolor sit amet”);
break;
case 14:
case 15:
case 16:
$dets = array(“img” => “image3.png”, “txt” => “Pellentesque habitant”);
break;
case 17:
case 18:
case 19:
case 20:
case 21:
case 22:
case 23:
case 24:
$dets = array(“img” => “image1.png”, “txt” => “Lorem ipsum”);
break;
}echo ““;
?>basically gets the date "now" you extract the hour and put it through a switch. I created an array just coz it was easier to store the stuff.
Edit: the hours are obviously in 24hr format…
April 26, 2010 at 5:15 am #74703ploughansenMemberThanks I’ll try that.
BTW where is it taking the time from? the local client or the server?
I would prefer it took the time from the server, and also that the timezone be UTC. That way everyone would get the same result no matter where in the world they are.Missed something:
I forgot to say that I want to specify the images and text per day also. Perhaps I should clearify what I want to use this for.
I want to show when the phones at our office are open, when there’s a chance of waiting time, and when they are closed.Open
green.png "Phones are open"
Mon-thu 8am-4pm (24H: 08:00-16:00)
fri 8am-3.30pm (24H: 08:00-15:30)
Waiting time
yellow.png "Phones are open. Expect waiting time"
Mon-fri 1pm-3pm (24H: 13:00-15:00)
Closed
red.png "Pones are closed"
Rest of the timeApril 26, 2010 at 5:50 am #74704Rob MacKayParticipanttime is taken from the server and it is relative to a UTC date – its "Unix timestamp (the number of seconds since January 1 1970 00:00:00 UTC)" so its UTC by default :)
April 26, 2010 at 6:34 am #74700ploughansenMemberThank you, it works perfect! :)
Well almost anyway… I don’t know If you saw my last edit, but I also need to specify per weekday, and per minute (08:00-15:30).
How would you go about that?PS Sorry if some of the questions are dumb – I’m still a noob when it comes to php ;)
April 26, 2010 at 10:24 am #74730Rob MacKayParticipantyes now you are getting into a bit more time coding wise… I don’t have the time to spend on it unfortunately – I was hoping you could get inspired :D
you might find this useful… as you pass the timestamp through the date function – you can pretty much pull everything out of it.
April 26, 2010 at 3:30 pm #74633ploughansenMemberNo problem… I’ll check out the php manual and see what I can find out.
Thanks for your help anyway! :)
April 26, 2010 at 4:05 pm #74634Rob MacKayParticipantNo probs – let us know how you get on – we might be able to keep pointing you in the right direction if you get stuck :)
May 8, 2010 at 3:52 am #75252ploughansenMemberJust wanted to check back with an update on this.
I got some help from a friend, and also the good folks at stckoverflow, and ended up with this solution.
-
AuthorPosts
- The forum ‘Back End’ is closed to new topics and replies.