OK, looks like I have fixed problem, using:

        $format = 'd/m/Y g:i:s A';
        $dt = date_create_from_format($format, $d[0]);
        $dt2 = date('r', $dt->getTimestamp());
        $data[] = array(strtotime($dt2), $d[1]);

Not elegant but it gives me the date/time value.

Thanks, Adam and Richard

DN

On 23/06/11 12:51 AM, Adam Balogh wrote:
$dt is an object as the error says, so you cant echo it, becouse its not a
string (it can be with __toString magic method, or use print_r/var_dump to
output your object). Try the format (
http://www.php.net/manual/en/datetime.format.php) method on your $dt object.

On Wed, Jun 22, 2011 at 4:41 PM, David Nicholls<d...@dcnicholls.com>  wrote:

On 23/06/11 12:23 AM, Adam Balogh wrote:

hi,

you have a PM(/AM) in your date ($d[0]), so put an "A" (Uppercase Ante
meridiem and Post meridiem) format char to your $format variable.

b3ha


Thanks, Adam.  Tried that and it's now throwing an error:

Catchable fatal error: Object of class DateTime could not be converted to
string in<xxx.php>  on line 12

Line 12 follows the attempt at conversion

10      $format = 'd/m/Y h:i:s A';
11      $dt = DateTime::createFromFormat($**format, $d[0]);
12      echo $dt,"...";

DN



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

Reply via email to