Try: $variable=sprintf('%4d%02d%02d', $yy, $mm, $dd));
----- Original Message ----- From: "Jeff Oien" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Saturday, March 20, 2004 11:36 AM Subject: Re: [PHP] Convert Date Format? > [EMAIL PROTECTED] wrote: > > > On 20 Mar 2004 Jeff Oien wrote: > > > > > >>How do I convert this > >>9/8/2001 > >>(which is Month/Day/Year) > >>to this > >>20010908 > >>(YearMonthDay - with leading zeros) > > > > > > How about: > > > > <?php > > $date = '9/8/2001'; > > list($mm, $dd, $yy) = explode('/', $date); > > print(sprintf('%4d%02d%02d', $yy, $mm, $dd)); > > ?> > > Can I put that print (sprintf etc. into a variable? Thanks. > Jeff Oien > > -- > 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