Thanks everyone for the helpful answers.

I agree that manuals are useful, but there are times when an example works 
better.

I took all of this information, and some details from earlier posts about 
dates, and produced the following function to make it easy to format dates 
without have to go through and change sql stmts.

# --- Function to format date output ---
function makedate($format, $indate)
{
         $temp = explode("-", $indate);
         $fulldate = mktime(0, 0, 0, $temp[1], $temp[2], $temp[0]);
         $temp = date($format, $fulldate);
         return ($temp);
}


The function gets called like this:

makedate('Y/m/d', $row->articledate);    or
makedate("F d, Y", $somedate);


Hopefully this will someone else with their date challenges.


Peter


At 02:55 PM 9/18/2002 -0400, Chuck Payne wrote:

>I know everyone love to quote read the manual and forget that we[newbies]
>are only asking here because we need help...so here you go...
>
>You can do the following...
>
>DATE_FORMAT IS THE MySQL Command
>
>And let say you want to format your date as the following mm-dd-yy(US) or
>dd-mm-yy(the rest of the world).
>
>By the way this are format keys....
>
>%m the month in numbers,
>%d the days in numbers,
>%y the year in number
>%M spells out the month
>%D gives the date with th, rd, nd all that
>%Y gives all four numbers
>
>So you do the following sql statement...
>
>SELECT DATE_FORMAT(yourdate, '%m-%d-%y') as youwanttocallit FROM yourtable;
>
>So in your php code you can do this from your MySQL statement...
>
>$youwantcallit = $myrow[youwanttoit];
>
><? echo $youwanttocallit; ?>
>
>Advance note
>
>then if you don't want to show 00-00-00 you can do this...
>
>if ($youwanttocallit == "00-00-00") {
>   $youwanttocallit = "&nbsp;";
>}
>
>that way you don't have a bunch of 00-00-00 showing up.
>
>I hope that helps, because that is what the maillisting is for and not to
>always quote "Read the Book".
>
>Chuck Payne
>Magi Design and Support
>
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php

- - - - - - - - - - - - - - - - - - - - -
Fourth Realm Solutions
[EMAIL PROTECTED]
http://www.fourthrealm.com
Tel: 519-739-1652
- - - - - - - - - - - - - - - - - - - - -


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

Reply via email to