rumeye Posted January 15, 2013 Share Posted January 15, 2013 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"? Quote Link to comment https://forums.phpfreaks.com/topic/273211-trying-to-read-date-from-tumblr-api/ Share on other sites More sharing options...
QuickOldCar Posted January 16, 2013 Share Posted January 16, 2013 This should do it $date = date("D, d M Y", strtotime($date)); Quote Link to comment https://forums.phpfreaks.com/topic/273211-trying-to-read-date-from-tumblr-api/#findComment-1406021 Share on other sites More sharing options...
rumeye Posted January 16, 2013 Author Share Posted January 16, 2013 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)]; Quote Link to comment https://forums.phpfreaks.com/topic/273211-trying-to-read-date-from-tumblr-api/#findComment-1406024 Share on other sites More sharing options...
QuickOldCar Posted January 16, 2013 Share Posted January 16, 2013 (edited) add the line I posted like so $date = $xml->posts->post ['date']; $date = date("D, d M Y", strtotime($date)); echo '<p>'.$date.'</p>'; Edited January 16, 2013 by QuickOldCar Quote Link to comment https://forums.phpfreaks.com/topic/273211-trying-to-read-date-from-tumblr-api/#findComment-1406026 Share on other sites More sharing options...
rumeye Posted January 16, 2013 Author Share Posted January 16, 2013 Thank you! so much it work!!! Quote Link to comment https://forums.phpfreaks.com/topic/273211-trying-to-read-date-from-tumblr-api/#findComment-1406157 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.