Re: how should MS Access DATETIME be handled in PHP?
| From: | Bing Du | Date: | Thu, 13 Apr 2006 15:10:29 +0000 |
| Subject: | Re: how should MS Access DATETIME be handled in PHP? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-233898@lists.php.net to get a copy of this message | ||
> apparently $rec[0] is a php object - try the following lines to
> find out what's inside:
>
> echo '<pre>';
> print_r($rec[0]);
> echo '<pre>';
>
> that will probably give you a clue as to how to extract some
> useful info from the object.
Excellent! Yes, it now does give me a clue to see what's actually in the
object. print_r($rec[0]) shows:
stdClass Object ( [year] => 2005 [month] => 8 [day] => 31 [hour] => 0
[minute] => 0 [second] => 0 [fraction] => 0 )
I've never dealt with object in PHP. Something new learnt today. I'm now
able to use get_object_vars($rec[0]) to extract the info from the object.
There is one thing I don't understand though.
Is there anything wrong with the follow code snippet? The result of echo
is 'using list, year is" rather than 'using list, year is 2005'.
==
list($year,$month,$day,$hour,$minute,$second,$fraction) =
get_object_vars($rec[0]);
echo "using list, year is $year<br>";
==
This one works. But I prefer using list.
==
$arr = get_object_vars($rec[0]);
echo "year is $arr[year]<br>";
==
Thanks,
Bing