Re: [PHP] date conversion/extraction issues

2012-05-03 Thread Terry Ally (Gmail)
Haluk,

After you retrieve the date from the database you still have to convert it
from a string to time and then to a date. Try:




Terry

On 2 May 2012 22:36, Haluk Karamete  wrote:

> This is my code and the output is right after that...
>
> $PDate = $row['PDate'];
> //row is tapping into ms-sql date field.
> //and the ms-sql data field has a value like this for the PDate;
> //07/12/2001
> $PDate = $PDate->date;
> echo "[", $PDate , "]";
> echo "[", var_dump($row['PDate']) , "]";
> echo "[", serialize($row['PDate']) , "]";
> the output is as follows. And my question is embedded in the output.
>
> []  ??? WHY IS THIS BLANK? WHY IS THIS NOT 2001-12-07 00:00:00?
>
> [object(DateTime)#3 (3) { ["date"]=> string(19) "2001-12-07 00:00:00"
> ["timezone_type"]=> int(3) ["timezone"]=> string(19)
> "America/Los_Angeles" } ]
>
> [O:8:"DateTime":3:{s:4:"date";s:19:"2001-12-07
>
> 00:00:00";s:13:"timezone_type";i:3;s:8:"timezone";s:19:"America/Los_Angeles";}]
>
> if I were to directly insert the $row['date']  ms-sql value into mysq,
> I get this error;
> Catchable fatal error: Object of class DateTime could not be converted
> to string in sql.php on line 379
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
*Terry Ally*
Twitter.com/terryally
Facebook.com/terryally
~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~
To print or not to print this email is the environmentally-searching
question!
Which has the highest ecological cost? A sheet of paper or constantly
switching on your computer and connecting to the Internet to read your
email?


Re: [PHP] date conversion/extraction issues

2012-05-02 Thread Jim Lucas

On 05/02/2012 02:36 PM, Haluk Karamete wrote:

This is my code and the output is right after that...

$PDate = $row['PDate'];
//row is tapping into ms-sql date field.
//and the ms-sql data field has a value like this for the PDate;
//07/12/2001
$PDate = $PDate->date;
echo "[", $PDate , "]";
echo "[", var_dump($row['PDate']) , "]";
echo "[", serialize($row['PDate']) , "]";
the output is as follows. And my question is embedded in the output.

[]  ??? WHY IS THIS BLANK? WHY IS THIS NOT 2001-12-07 00:00:00?

[object(DateTime)#3 (3) { ["date"]=>  string(19) "2001-12-07 00:00:00"
["timezone_type"]=>  int(3) ["timezone"]=>  string(19)
"America/Los_Angeles" } ]

[O:8:"DateTime":3:{s:4:"date";s:19:"2001-12-07
00:00:00";s:13:"timezone_type";i:3;s:8:"timezone";s:19:"America/Los_Angeles";}]

if I were to directly insert the $row['date']  ms-sql value into mysq,
I get this error;
Catchable fatal error: Object of class DateTime could not be converted
to string in sql.php on line 379



I think you need to double check your variable names.  In one place you 
are using $row['PDate'] in another you are referring to $row['date']


--
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
http://www.bendsource.com/

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



Re: [PHP] date conversion/extraction issues

2012-05-02 Thread Matijn Woudt
On Wed, May 2, 2012 at 11:36 PM, Haluk Karamete  wrote:
> This is my code and the output is right after that...
>
> $PDate = $row['PDate'];
> //row is tapping into ms-sql date field.
> //and the ms-sql data field has a value like this for the PDate;
> //07/12/2001
> $PDate = $PDate->date;
> echo "[", $PDate , "]";
> echo "[", var_dump($row['PDate']) , "]";
> echo "[", serialize($row['PDate']) , "]";
> the output is as follows. And my question is embedded in the output.
>
> []      ??? WHY IS THIS BLANK? WHY IS THIS NOT 2001-12-07 00:00:00?
>
> [object(DateTime)#3 (3) { ["date"]=> string(19) "2001-12-07 00:00:00"
> ["timezone_type"]=> int(3) ["timezone"]=> string(19)
> "America/Los_Angeles" } ]
>
> [O:8:"DateTime":3:{s:4:"date";s:19:"2001-12-07
> 00:00:00";s:13:"timezone_type";i:3;s:8:"timezone";s:19:"America/Los_Angeles";}]
>
> if I were to directly insert the $row['date']  ms-sql value into mysq,
> I get this error;
> Catchable fatal error: Object of class DateTime could not be converted
> to string in sql.php on line 379
>

Have you enabled all warnings in PHP, and checked the Apache error log
after that? It probably contains a hint on why it doesn't work...

- Matijn

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