Re: [PHP] Need a better way...

2002-10-27 Thread Jonathan Sharp
function mysql_to_date($mysql)
{
return ( $mysql ? date('m/d/Y', strtotime($mysql) ) : '' );
}

-js


Todd Cary wrote:

My coding is not very concise and I would appreciate suggestions on how 
to clean this up even though it works:

 /* MySQL to date */
 function mysql_to_date($mysql) {
   $retval = ;
   if ($mysql) {
 $parts = explode(-, $mysql);
 $mo = $parts[1];
 $dy = $parts[2];
 $yr = $parts[0];
 $parts = explode( , $dy);
 $dy = $parts[0];
 $retval = $mo . / . $dy . / .  $yr;
   } else {
 $retval = ;
   }
   return $retval;
 }





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




RE: [PHP] Need a better way...

2002-10-27 Thread John W. Holmes
Why not use DATE_FORMAT in your query, then you don't have to do any
extra PHP at all?

---John Holmes...

 -Original Message-
 From: Jonathan Sharp [mailto:js-lists;sharpmedia.net]
 Sent: Sunday, October 27, 2002 1:45 PM
 To: Todd Cary
 Cc: [EMAIL PROTECTED]
 Subject: Re: [PHP] Need a better way...
 
 function mysql_to_date($mysql)
 {
  return ( $mysql ? date('m/d/Y', strtotime($mysql) ) : '' );
 }
 
 -js
 
 
 Todd Cary wrote:
  My coding is not very concise and I would appreciate suggestions on
how
  to clean this up even though it works:
 
   /* MySQL to date */
   function mysql_to_date($mysql) {
 $retval = ;
 if ($mysql) {
   $parts = explode(-, $mysql);
   $mo = $parts[1];
   $dy = $parts[2];
   $yr = $parts[0];
   $parts = explode( , $dy);
   $dy = $parts[0];
   $retval = $mo . / . $dy . / .  $yr;
 } else {
   $retval = ;
 }
 return $retval;
   }
 
 
 
 
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




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