Re: newbie date time question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



$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 <dcn@xxxxxxxxxxxxxx> 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

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux