Date::Period::Human - Human readable date periods
# Create the Date::Period::Human object my $d = Date::Period::Human->new(); # Get a relative human readable date string my $s = $d->human_readable('2010-01-01 02:30:42'); # Now $s contains the relative date in human readable form, e.g. "1 year # ago", "3 weeks ago", etc. # Use English instead of the default Dutch # my $d = Date::Period::Human->new({ lang => 'en' });
Creates a string of relative time. This is useful when you're showing user created content, where it's nicer to show how long ago the item was posted (e.g. "3 weeks ago") instead of the date and time.
This also solves the problem where you don't know the timezone of the user who is viewing the item. This is solved because you show relative time instead of absolute time in most cases.
There is one case that isn't relative.
This class contains one public class method.
The language you want to use. Default 'nl', can be 'en' for English.
An arrayref containing [ $year, $month, $day, $hour, $min, $sec ].
Will be used as the fixed point from which the relative time will be calculated.
This class contains one public method.
Parses the $mysql_date and returns a human readable time string.
Or, $datetime (a DateTime object) and returns a human readable time string.
Or, $epoch (identified by regex /^\d+$/) and passed through gmtime().
http://github.com/pstuifzand/date-period-human
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Peter Stuifzand <peter@stuifzand.eu>
Copyright 2010 Peter Stuifzand
To install Date::Period::Human, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Date::Period::Human
CPAN shell
perl -MCPAN -e shell install Date::Period::Human
For more information on module installation, please visit the detailed CPAN module installation guide.