Kevin Murphy wrote:
date("a");  > output = AM

Is there any easy way to change the formatting of the output of above from "am" to "a.m." in order to conform to AP style?

Something like this below would work, but I'm wondering if there is something I could do differently in the date() fuction to make it work:

$date = date("a");
if ($date == "am")
{ echo "a.m."    }
elseif ($date == "pm")
{ echo "p.m."    }


The date function itself doesn't support it, but you don't need IFs.

To replace your example: echo str_replace(array("am", "pm), array("a.m.", "p.m."), date("a"));

And to do the replacement on a full data/time:

echo str_replace(array("am", "pm), array("a.m.", "p.m."), date("g:i a"));

which would output something like "12:52 p.m."

Regards, Adam Zey.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to