Laugh at . . . *ahem* . . . with me. (military time)
Posted: Sat Sep 20, 2003 9:24 pm
Well, I recently got into the whole getlastmod() function and, from the examples that I was looking at (thanks a lot php.net!), I used "H" to display the hour.
Weeeeeeelllllll, this just wasn't sufficient for my needs because I hate reading military time. I think its annoying and other things, but thats for another article. Anyway, I decided to go about writing a little script that converts the military time to standard am, pm stuff.
Being a beginner, or relative beginner, this task took me quite some time (about 45 minutes) and gave me a pretty decent headache. I ended up taking two ibuprofen and finishing a pretty awesome, useful (har har) script! You wanna see it?
Now, we all know that I could have just done away with all of that work and just put "h" in place of "H" and done the EXACT SAME thing! Okay, so now you can laugh at me. However, before you do, please take into consideration that I am a newbie AND, most importantly, I did write code to fix my problem instead of posting a dumb question on this forum! Laugh it up, guys and don't steal my VERY USEFUL
script . . .
Yuk, Yuk,
Brandon
Weeeeeeelllllll, this just wasn't sufficient for my needs because I hate reading military time. I think its annoying and other things, but thats for another article. Anyway, I decided to go about writing a little script that converts the military time to standard am, pm stuff.
Being a beginner, or relative beginner, this task took me quite some time (about 45 minutes) and gave me a pretty decent headache. I ended up taking two ibuprofen and finishing a pretty awesome, useful (har har) script! You wanna see it?
Code: Select all
/* Copyright © 2003 Brandon Paredes. All rights reserved.
brandon@paredes.cc */
$hour_convert = date ("H", getlastmod());
$hour = 0;
if ($hour_convert > 12) {
$hour = $hour_convert - 12;
} else {
$hour = $hour_convert;
}
$am_pm = " ";
if ($hour_convert < 13) {
$am_pm .= "am";
} else {
$am_pm .= "pm";
}
echo "<b>Date Uploaded:</b> " . date ("F d Y $hour:i", getlastmod());
echo "$am_pm.";
echo "<br>";Yuk, Yuk,
Brandon