DateStringParser class - Natural Language Parsing
Have you ever used Google Calendar, where you just enter sentences, and it parses out the date?
In example, "I have a meeting with Jane tomorrow at 3:00PM" will give you tomorrow's date, along with 3:00PM.
It's called Natural Language Parsing, and with this class, you can easily implement natural language parsing, using just 1 function.
Only a handful of sites currently implement this, Google Calendar being one of them. There's currently no known PHP implementation.
The core of this class is built on PHP's strtotime() function, which is a powerful parsing function built in both PHP4 and PHP5.
It's easy as:
$parser = new DateStringParser();
echo $parser->nltotime("tomorrow i am going to grab lunch", "Y-m-d");
which will return tomorrow's date in Y-m-d format.
You can also return filtered string,
which will return "i am going to grab lunch"
DateStringParser class - Time Ago
NOTE: This feature can support multiple languages with ease! Check documentation for multi-language support.
With this class, you can customize it the way you want it. You can add your own language, change wordings, or even fix granularity.
It's easy as:
echo $parser->time_ago("2011-1-2 03:00:00", 3);
which will return "one year, 4 days, 59 minutes ago"
echo $parser->time_ago("2011-1-2 03:00:00", 1);
which will return "one year ago"
Check documentation for further details on how to customize this feature.