This is my PHP/MySQL query, as mentioned at Displaying links in PHP/MySQL?:
http://pastebin.com/5Td9Bybn
I\'ll admit, I\'ve forgotten how to use the strtotime()
The PHP function strtotime() has the following usage:
int strtotime ( string $time [, int $now ] )
This means that you pass in a string value for the time, and optionally a value for the current time, which is a UNIX timestamp. The value that is returned is an integer which is a UNIX timestamp.
An example of this usage is as follows, where the date passed to strtotime() might be a date from a database query or similar:
$ts = strtotime('2007-12-21');
This will return into the $ts variable the value 1198148400, which is the UNIX timestamp for the date December 21st 2007. This can be confirmed using the date() function like so:
echo date('Y-m-d', 1198148400);
// echos 2007-12-21
strtotime() is able to parse a wide variety of strings and convert them to the appropriate timestamp, using actual dates and also strings such as "next week", "next tuesday", "last thursday", "2 weeks ago" and so on. Here are some examples:
$ts = strtotime('21 december 2007');
echo $ts, '
';
echo date('Y-m-d', $ts), '
';
This will display the following:
1198148400 2007-12-21
If today is December 21st, then the following:
$ts = strtotime('next week');
echo $ts, '
';
echo date('Y-m-d', $ts), '
';
$ts = strtotime('next tuesday');
echo $ts, '
';
echo date('Y-m-d', $ts), '
';
$ts = strtotime('last thursday');
echo $ts, '
';
echo date('Y-m-d', $ts), '
';
$ts = strtotime('2 weeks ago');
echo $ts, '
';
echo date('Y-m-d', $ts), '
';
$ts = strtotime('+ 1 month');
echo $ts, '
';
echo date('Y-m-d', $ts), '
';
will display the following:
1199006542
2007-12-30
1198494000
2007-12-25
1198062000
2007-12-20
1197192142
2007-12-09
1201080142
2008-01-23