Re: Convert Date Format?

From: Date: Sat, 20 Mar 2004 16:41:47 +0000
Subject: Re: Convert Date Format?
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-181037@lists.php.net to get a copy of this message
Try: $variable=sprintf('%4d%02d%02d', $yy, $mm, $dd)); ----- Original Message ----- From: "Jeff Oien" <jeff@webdesigns1.com> To: <trlists@clayst.com> Cc: <php-general@lists.php.net> Sent: Saturday, March 20, 2004 11:36 AM Subject: Re: [PHP] Convert Date Format? > trlists@clayst.com 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 >

« previous php.general (#181037) next »