RE: [PHP] Hi How to convert the mysql(DATETIME) time to the format DD/MM/YYYY HH:MM AM or PM using PHP?

2002-03-12 Thread Balaji Ankem


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 -MM-DD
HH:MM:SS.


Is it possible to convert it to DD/MM/ 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';

Thanks in advance.
Balaji



-Original Message-
From: Jason Wong [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, March 12, 2002 4:09 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Hi How to convert the time from mysql(DATETIME) table
to the format DD/MM/ HH:MM AM or PM in PHP?



 Hi,
   I have stored the date and time in mysql table with DATETIME
type.

   I want to change it in to DD/MM/ HH:MM AM or PM.

   How can I do this?

When you select the 'datetime' field from mysql use UNIX_TIMESTAMP().

Then in PHP use strftime() to format the 'datetime' field to your
liking.



-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk

/*
Happiness isn't something you experience; it's something you remember.
-- Oscar Levant
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



**Disclaimer
  


Information contained in this E-MAIL being proprietary to Wipro Limited
is 'privileged' and 'confidential' and intended for use only by the
individual or entity to which it is addressed. You are notified that any
use, copying or dissemination of the information contained in the E-MAIL
in any manner whatsoever is strictly prohibited.



 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Hi How to convert the mysql(DATETIME) time to the format DD/MM/YYYY HH:MM AM or PM using PHP?

2002-03-12 Thread Jason Wong

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 -MM-DD
 HH:MM:SS.


   Is it possible to convert it to DD/MM/ 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.
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php