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

ManiacalRage.net:
Relative Dates Using PHP
Jul 01, 2005 @ 14:27:47

For all of the Wordpress users out there (and well, anyone else that would want to use it), ManicalRage.net has a post to help you get "relative dates" in a simple, includable script.

So you want to jump on the relative dates bandwagon? Here's how you can do it quickly and easily. This tutorial will assume you're using Movable Type, but you can use the PHP bit on its own if you wish.

[...] The idea here is simple: You pass the function a date stamp in a specific format (YYYYMMDDHHMMSS) and it converts that stamp into a Unix timestamp (in seconds since the Epoch). It then finds the difference between the current time and that timestamp. This number is the number used to calculate the relative values.

The result is something like "4 weeks, 3 days, 8 hours, 32 minutes, 11 seconds" and can be gotten through one function call, passing in the datestamp in the YYYYMMDDHHMMSS format.

tagged:

Link:


Trending Topics: