News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

ThinkPHP Blog:
Put out the age of a date in words
April 11, 2008 @ 10:37:53

On the ThinkPHP blog today, Annika Rabea shares a method for outputting dates in words rather than in the usual numbers most applications use.

Recently, I have to output the age of a date in words and didn't have a framework to work with. The first steps were to parse the given date into an array and create a timestamp with the individual parts. The difference between the timestamp of now and the created timestamp yielded the age in seconds. The result can be used to compare with seconds of a day, week, etc.

The code snippet in the post outputs the difference between two timestamps (then and now) it a bit more friendly way (ex. 4 months, 2 weeks, 2 days).

0 comments voice your opinion now!
date format timestamp week month day output


blog comments powered by Disqus

Similar Posts

Matthew Weier O'Phinney's Blog: Creating composite elements

Derick Rethans' Blog: What is PHP doing?

Ilia Alshanetsky\'s Blog: PHP 5.1.1 Released! (and a Rant)

PHPClasses.org: Lately in PHP podcast episode 17 - PHP 5.4 & PHP-GTK in the Browser

DevShed: Using HTTP Compression in PHP - Make Your Web Pages Load Faster


Community Events





Don't see your event here?
Let us know!


introduction bugfix podcast laravel threedevsandamaybe application framework code library series list developer release configure language interview community project api wordpress

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework