Jump to content

Trying to read "Date" from Tumblr api


rumeye

Recommended Posts

Hi PHP expert, I am trying to read the post date from my tumblr api with the following code.

 

$date = $xml->posts->post ['date'];

 

echo '<p>'.$date.'</p>';

 

This is what I get from the above code "Wed, 21 Nov 2012 13:32:00"

 

My question is, are there anyways I can get the date with out the hour, min and seconds? for example "Wed,21 Nov 2012"?

Link to comment
https://forums.phpfreaks.com/topic/273211-trying-to-read-date-from-tumblr-api/
Share on other sites

Thanks for the reply, with the above code will only show the local date. what I am trying to do is the pull the date from a Tumblr XML API as below.

 

<posts start="1" total="77">

<post id="38470857535" url="http://myblog.tumblr.com/post/38470857535" url-with-slug="http://myblogblog.tumblr.com/post/38470857535" type="photo"date-gmt="2012-12-21 16:38:51 GMT" date="Fri, 21 Dec 2012 11:38:51" unix-timestamp="1356107931" format="html" reblog-key="3ZWYJfgn" slug="" width="1064">

 

 

And I used the code below to call it:

 

<?php

$request_url = "http://myblog.tumblr.com/api/read?start=0&num=1";

$xml = simplexml_load_file($request_url);

 

$date = $xml->posts->post ['date'];

 

in order to get the posting date I need to "= $xml->posts->post ['date'];" so is there anyway to do something like = $xml->posts->post ['date'("D, d M Y", strtotime($date)];

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.