How would i convert a format like:
13 hours and 4 mins ago
Into something i can use in php to further convert?
try
strtotime('13 hours 4 mins ago', time())
http://php.net/manual/en/function.strtotime.php
Try the DateInterval class - http://www.php.net/manual/en/class.dateinterval.php - which you can then sub() from a regular DateTime object.
Do it the hard way:
$offset = (time() - ((60 * 60) * 13) + (4 * 60));
Working Example: http://codepad.org/25CJPL76
Explanation:
(60 * 60) is 1 hour, then * 13 to make 13 hours, plus (4 * 60) for the 4 minutes, minus the current time.
What i usually do is create several constants to define the values of specific time values like so:
define("NOW",time());
define("ONE_MIN", 60);
define("ONE_HOUR",ONE_MIN * 60);
define("ONE_DAY", ONE_HOUR * 24);
define("ONE_YEAR",ONE_DAY * 365);
and then do something like:
$offset = (NOW - ((ONE_HOUR * 13) + (ONCE_MIN * 4)));
in regards to actually parsing the string, you should look at a javascript function and convert to PHP, the source is available from PHP.JS:
strtotime()seems to fail... The best way would not to have to parse natural language in the first place. Where is this coming from? No chance of getting a more machine-readable format?