scriptygoddess

27 Nov, 2002

Wording based on time

Posted by: kristine In: MT hacks

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! :)

11 Responses to "Wording based on time"

1 | Tudy

November 27th, 2002 at 11:30 pm

Avatar

Maybe you could direct me to a php tutorial online somewhere? :-) Please.

2 | kristine

November 29th, 2002 at 6:59 pm

Avatar

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! :)

3 | skits

November 29th, 2002 at 7:22 pm

Avatar

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?)

4 | maddy

December 1st, 2002 at 2:16 am

Avatar

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. :)

5 | Nilesh

December 2nd, 2002 at 1:11 am

Avatar

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. :-)

6 | skits

December 2nd, 2002 at 5:17 pm

Avatar

Thanks, Maddy. I'm stilling the learning stages over here. 😀

7 | maddy

December 3rd, 2002 at 12:26 am

Avatar

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! :)

8 | kadyellebee

November 27th, 2002 at 6:41 pm

Avatar

postings
I'm doing some housekeeping on my desk, and had a few things that needed posting on several of my blogs

9 | maddy's rambles

December 1st, 2002 at 2:16 am

Avatar

Pastel Pastiche
How I ended up using pastel colours in this "design" I do not know. I'm not really big on pastel

10 | J : Da Blog

December 15th, 2002 at 6:46 am

Avatar

PHP and more
My page now has a .php extension. I've probably been living under a rock, but I had no idea you

11 | J : Da Blog

December 15th, 2002 at 6:46 am

Avatar

PHP and more
My page now has a .php extension. I've probably been living under a rock, but I had no idea you

Featured Sponsors

Genesis Framework for WordPress

Advertise Here


  • Scott: Just moved changed the site URL as WP's installed in a subfolder. Cookie clearance worked for me. Thanks!
  • Stephen Lareau: Hi great blog thanks. Just thought I would add that it helps to put target = like this:1-800-555-1212 and
  • Cord Blomquist: Jennifer, you may want to check out tp2wp.com, a new service my company just launched that converts TypePad and Movable Type export files into WordPre

About


Advertisements