Re: display date
| From: | Joe Stump | Date: | Sun, 17 Dec 2000 21:30:38 +0000 |
| Subject: | Re: display date | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-30773@lists.php.net to get a copy of this message | ||
Well since your string $r[4] == 'Dec 16, 2000' and you want to return the same
thing then what's wrong here? Just echo out your $r[4] ... if it contains a
datetime stamp like mysql's (YYYY-MM-DD HH:II:SS) then you want to do something
like this:
<?
$date = '2000-12-17 13:29:04';
$foo = explode(' ',$date);
$more_foo = explode('-',$foo[0]);
$year = $more_foo[0];
$month = $more_foo[1];
$day = $more_foo[2];
$timestamp = mktime(0,0,0,$month,$day,$year);
echo date("M d, Y",$timestamp);
?>
Remember that date() only takes an INT timestamp as a second argument.
--Joe
On Sun, Dec 17, 2000 at 04:24:57PM -0500, Ignacio Vazquez-Abrams wrote:
> On Sun, 17 Dec 2000 wooik@halfmind.com wrote:
>
> > Before I asked my question, just want to let you all know that I did look
> > up the manual to find the answer, but can't seem to find it.
> >
> > Anyway, the problem that I have: I have a postgres database the returns a
> > datetime field. I want to display it as MMM DD, YYYY (e.g. Nov 15, 2000),
> > The following is what I have
> >
> > <?php echo date("M d, Y", $r[4]); ?> <== $r[4] contains Dec 16, 2000
> >
> > but what I got back is "Dec 31, 1969".
> >
> > Am I missing something again??
> >
> > wooi.
> > p/s Brain, if you are reading this email, just want to thank you for
> > answering me my previous question :-) But I did try to find the answer in
> > the php manual and some other php sites.
> >
>
> It's probably because the datetime looks like a string to PHP, and PHP
> converts strings that don't start with a number into 0.
>
> --
> Ignacio Vazquez-Abrams <ignacio@openservices.net>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
---
Joe Stump
PHP Programmer
www.Care2.com