0

From JSON I get:

stdClass Object ( [$t] => 2011-12-12T13:00:00.000Z )

How can I get this date out using PHP?

I tried: feed->item->'$t' and that did not work...

1

3 Answers 3

1

This should work:

$t = $feed->item->{'$t'};

Beware: This will only work with single quotes, because PHP does variable interpolation on strings with double quotes.

Sign up to request clarification or add additional context in comments.

1 Comment

I also find it easier to just work with arrays json_decode($json, true).
0

You need to use {} to get properties in that way.

$feed->item->{'$t'}

Comments

0

Try:

$item = $feed->item->{$t};

The {$notation} allows you to use vars as object names.

1 Comment

In this case the property is literally '$t'.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.