All Topics:
apps
css
dashboard
games
javascript
php
tehcl
textmate
tools
video

Topic: php

Be Careful Using PHP's empty()

published:
2009.02.09
topics:
php

Glen Stansberry recently shared his great tutorial about 10 PHP Mistakes, but I thought there was one other mistake so important and easy to make that it was worth explaining: PHP programmers of all skill levels can easily use the empty() language construct incorrectly.


Relative Date / Time Strings in PHP

published:
2009.01.20
topics:
php

I've noticed that Facebook, Twitter, and lots of other sites are using a relative date and time string description for user posts and comments. For example, "comment written about 3 months ago" instead of "comment written on October 20, 2008." I decided to do the same thing on this site, although rather than saying "3 months ago" I made it say "T plus 3 months." I adopted the NASA language for keeping track of post-launch time. If you've ever heard a NASA employee (or an actor portraying a NASA employee) say, "T minus 1 minute to lift off," that is their standard language for pre-launch time. Same idea. (Perhaps I'm taking this space thing a little too far... whatever. All in good fun.)

I want to share the PHP function I wrote to convert the timestamp of a comment or Tweet — or anything else — into a relative time string. Code after the bump.