Re: Date Formatting

From: Date: Sat, 25 Sep 2004 14:48:39 +0000
Subject: Re: Date Formatting
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-24643@lists.php.net to get a copy of this message
Trevor: I prefer date( '(T) d-M-y h:ia +Z"' ); Regards. --- José Enrique http://jese.alcorce.org --- "Trevor Gryffyn" <TGryffyn@air-cargo-inc.com> escribió en el mensaje news:B97E3961173C4943BF7C722DFE31943D916108@irmailee1024.root.aircargo.com... I know a lot of people will recommend using strtotime() to convert it to a unix timestamp, then use date() to format that: Date("m/d/Y",strtotime("Sep 12 2004 2:16AM")) That may work.. I have an inherent distrust of functions that use too much logic that isn't apparent to me, so I don't use strtotime() hoping to avoid it misinterpreting the date/time string I'm giving it. I prefer full control. I'd do it the hard way just to have confidence in the results (there's probably a better "hard way" as well, but here's the quick and dirty): <?php $months = array("Jan"=>1,"Feb"=>2,"Mar"=>3,"Apr"=>4,"May"=>5,"Jun"=>6,"Jul"=>7,"Au g"=>8,"Sep"=>9,"Oct"=>10,"Nov"=>11,"Dec"=>12); $origdate = "Sep 12 2004 2:16AM"; List($textmonth,$day,$year,$time) = explode(" ",$origdate); $newdate = Date("m/d/Y",mktime(0,0,0,$months[$textmonth],$day,$year); ?> But that's just one way to skin this cat. -TG > -----Original Message----- > From: Ron.Herhuth@tatumpartners.com > [mailto:Ron.Herhuth@tatumpartners.com] > Sent: Wednesday, September 22, 2004 9:13 AM > To: php-windows@lists.php.net > Subject: [PHP-WIN] Date Formatting > > > > I see in the manual about how to format the current date > using the date() > function...but my question is...I have the date in this format: > Sep 12 2004 2:16AM > > And I needed it formatted as: > 09/12/2004 (I don't need the time) > > How do I go about doing that? > > Thanks, > Ron > > > > > >

« previous php.windows (#24643) next »