Re: Date problem
| From: | David Robley | Date: | Tue, 22 Aug 2000 04:46:05 +0000 |
| Subject: | Re: Date problem | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-12877@lists.php.net to get a copy of this message | ||
On 21 Aug, Hector M Banda wrote:
> Hi all,
>
> let's say:
> thedate$ = "2000-12-31"
>
> how can I change the format to 12/31/2000?
>
> I've been looking into the date command but I get:
> date("mdY", thedate$) ==> 31121969
>
> Thx,
One possibility:
$datearray = explode("-", $thedate);
$newformat = $datearray[1] . '/' . $datearray[2] . '/' . $datearray[0];
Or you could feed the array elements to mktime to get a unix datestamp
and then feed the result back to date - if you want to chew up some
processor time :-)
If you are getting it from a database the DB may have date handling
functions you can use.
Cheers
--
David Robley | WEBMASTER & Mail List Admin
RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/
AusEinet | http://auseinet.flinders.edu.au/
Flinders University, ADELAIDE, SOUTH AUSTRALIA