Re: Hi How to convert the mysql(DATETIME) time to the format DD/MM/YYYY HH:MM AM or PM using PHP?
| From: | Jason Wong | Date: | Tue, 12 Mar 2002 13:52:11 +0000 |
| Subject: | Re: Hi How to convert the mysql(DATETIME) time to the format DD/MM/YYYY HH:MM AM or PM using PHP? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-88195@lists.php.net to get a copy of this message | ||
On Tuesday 12 March 2002 19:43, Balaji Ankem wrote:
> Hi friend,
> I never ued strftime function. I am confusing with the syntax.
>
> My problem is like this:
>
> I have the DATETIME in the variable $row->fromdate as YYYY-MM-DD
> HH:MM:SS.
>
>
> Is it possible to convert it to DD/MM/YYYY HH:MM AM or PM using
> strftime() function?
>
>
> //Is below code is correct
>
> $time=strftime([%a%b%C%d%I%p],$row->fromdate);
>
> echo '$time';
strftime() requires a unix-timestamp as an input.
In your db query do:
SELECT UNIX_TIMESTAMP(fromdate) AS from_date FROM table;
Then:
$time=strftime("some format", $row->from_date);
hth
--
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
/*
If you are honest because honesty is the best policy, your honesty is corrupt.
*/