php-windows Digest 25 Sep 2004 14:48:42 -0000 Issue 2409
Topics (messages 24643 through 24643):
Re: Date Formatting
24643 by: JESE
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[EMAIL PROTECTED]
----------------------------------------------------------------------
--- Begin Message ---
Trevor:
I prefer date( '(T) d-M-y h:ia +Z"' );
Regards.
---
Jos� Enrique
http://jese.alcorce.org
---
"Trevor Gryffyn" <[EMAIL PROTECTED]> escribi� en el mensaje
news:[EMAIL PROTECTED]
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: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, September 22, 2004 9:13 AM
> To: [EMAIL PROTECTED]
> 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
>
>
>
>
>
>
--- End Message ---