hiitsaaron — 2010-03-29T10:55:56-04:00 — #1
I've made a function to grab an RSS feed and I'm displaying it, however, each time I come across a date, the RSS uses '2010-03-27T22:38:32Z', for example.
I have no idea how to turn that into something more readable. Any help?
Also, on the feed, I get codes like '…', however it turns into 'â€¦' once displayed on the screen. I'm using SimpleXML, and I was wondering if there was a function to convert it back into normal characters? Cheers
crmalibu — 2010-03-29T10:57:00-04:00 — #2
try strtotime() and then feed the result to date()
hiitsaaron — 2010-03-29T11:11:49-04:00 — #3
Oh sick! Thanks very much! It works perfectly! Have you got any clue on my second problem?
Also.. is there anyway way to turn that time into 'posted an hour ago', or 'posted 16 hours ago' or 'posted yesterday' - much like Twitter does it?
crmalibu — 2010-03-29T12:32:37-04:00 — #4
For the time period formatting, see the user comments for an idea of how it's done
http://www.php.net/manual/en/function.time.php (use browser find in page feature, search for occurances of "minute")
You basically find the difference in seconds between a time, and the current time. You then find the largest(or smallest) interval that it fits into.
The browser should be able to display an html character entity like …
I bet your script doesn't actually output that character entity(check, view the html source).
Things get complicated once you want to start displaying non ascii characters. There is no simple way. Aggregating data from other websites into your own complicates things. If it's important that you get it right, you really should consider reading up on character sets, character encodings, and unicode. It will take some effort.
If you're looking for a quick fix that only works sometimes, pass the string through htmlentities().
hiitsaaron — 2010-03-29T20:49:56-04:00 — #5
Perfect. I found a user-created function that works perfectly!
Yeah, you were right. It was only until I defined a charset that the browser displayed the characters correctly.. I was testing it the script on a separate page, with nothing declared in the <head>, lol..
Thanks for the responses!
ren — 2010-03-29T21:14:15-04:00 — #6