Different output for time of day for each post
-
Hi all,
This may be a little complicated, but I hope someone can help π
I would like each post to have a time range and have a different output depending on the time of day. All my posts are adverts for different businesses, and I want to display if they are open or not. As well as on the post itself, it will display on the category listing for each post.
I was thinking of tagging each post with whole hours. If the business was open between 1pm and 5pm, then I would tag with 13, 14, 15, 16 then I could use the if(has_tag(”)) to compare to the server time and if match then output an “Open” image or text. If the tag and server time don’t match, then output a “Closed” image or text.
Unfortunately if I did that, I would have to have 24 if(has_tag(‘)) statements and if they open at 9.30am it would be wrong for half an hour. I also don’t know the php code to compare the tag to the server time.
Can anyone help, or think of an easier way to do it?
Many thanks in advance!!!!
- The topic ‘Different output for time of day for each post’ is closed to new replies.