Wording based on time
Would you like to have a different saying below your post based on what time it was posted instead of (or in addition to) the date? A poster on the MT forums did, so I cooked up this little script yesterday.
<?
//set the beginning time for each time section - keep the quotes in there
$earlymorn = strtotime(”4:30am”);
$midmorn = strtotime(”9:00am”);
$lunch = strtotime(”11:30am”);
$afternoon = strtotime(”1:00pm”);
$evening = strtotime(”5:00pm”);
$bedtime = strtotime(”9:00pm”);
//This date format is for MT2.5 and above
$t = strtotime(”<$MTEntryDate format=”%X”$>”);
//Modify the messages as necessary - note that the middle of the night one should be in there twice.
if ($t <= $earlymorn) { echo “Past Your Bedtime”; }
elseif ($t <= $midmorn) { echo “Early Morning”; }
elseif ($t <= $lunch) { echo “Mid-Morning”; }
elseif ($t <= $afternoon) { echo “Lunch time”; }
elseif ($t <= $evening) { echo “Afternoon”; }
elseif ($t <= $bedtime) { echo “Evening”; }
else echo “Past your bedtime”;
?>
Enjoy! ![]()
November 27th, 2002 at 6:41 pm
I’m doing some housekeeping on my desk, and had a few things that needed posting on several of my blogs
November 27th, 2002 at 11:30 pm
Maybe you could direct me to a php tutorial online somewhere?
Please.
November 29th, 2002 at 6:59 pm
Our Resources page points to a few great PHP resources.
And I made a post not too long ago with some more great starting-out links.
Hope that helps!
November 29th, 2002 at 7:22 pm
This is awesome cool–thank you! One quick question…does your entire page have to utilize php to use this? (I’ve inserted the script into my MT template and I’m pretty sure I’ve done it correctly, but nothing shows up–do I have to put anything in the header?)
December 1st, 2002 at 2:16 am
How I ended up using pastel colours in this “design” I do not know. I’m not really big on pastel
December 1st, 2002 at 2:16 am
This rocks, Kristine! Thank’s heaps. And Skits, your page will need to have the .php extension, or your server must parse html pages for php scripts.
December 2nd, 2002 at 1:11 am
Neat!
And in case you needed to know at what times you have blogged this month, you can have a look at my MTBlogTimes plugin (or here). Maybe this is a shameless plug, but worth a look at.
December 2nd, 2002 at 5:17 pm
Thanks, Maddy. I’m stilling the learning stages over here.
December 3rd, 2002 at 12:26 am
Hey, mcroft just posted a way to do this with the MTMacros Plugin for those that don’t have php. It’s all in the link that Kristine referenced up there for the MT forums!
December 15th, 2002 at 6:46 am
My page now has a .php extension. I’ve probably been living under a rock, but I had no idea you
December 15th, 2002 at 6:46 am
My page now has a .php extension. I’ve probably been living under a rock, but I had no idea you