Turning 2010-03-27T22:38:32Z into a more readable time?

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 ‘&#8230’, 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 :slight_smile:

try strtotime() and then feed the result to date()

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? :slight_smile:

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().

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! :slight_smile:

If you are using a recent version of PHP (5.3+) then

http://www.php.net/manual/en/intldateformatter.format.php