aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMike Macgirvin <mike@macgirvin.com>2010-07-09 22:47:32 -0700
committerMike Macgirvin <mike@macgirvin.com>2010-07-09 22:47:32 -0700
commitcb54cda17454fde783c165c37d6ece1ba2067253 (patch)
treefbb8ad7380fa713c066b7accd171b55231577d79 /include
parent51b51bd039d85573cb508c28811df52f198fa210 (diff)
downloadvolse-hubzilla-cb54cda17454fde783c165c37d6ece1ba2067253.tar.gz
volse-hubzilla-cb54cda17454fde783c165c37d6ece1ba2067253.tar.bz2
volse-hubzilla-cb54cda17454fde783c165c37d6ece1ba2067253.zip
more directory work
Diffstat (limited to 'include')
-rw-r--r--include/datetime.php22
1 files changed, 21 insertions, 1 deletions
diff --git a/include/datetime.php b/include/datetime.php
index f75193b1b..0beadbe78 100644
--- a/include/datetime.php
+++ b/include/datetime.php
@@ -115,7 +115,8 @@ function relative_date($posted_date) {
$diff -= $minutes*60;
$seconds = $diff;
-
+ if($months > 2)
+ return(datetime_convert('UTC',date_default_timezone_get(),$posted_date,'\o\n Y-m-d \a\t H:i:s'));
if ($months>0) {
// over a month old,
return 'over a month ago';
@@ -143,3 +144,22 @@ function relative_date($posted_date) {
// show relative date and add proper verbiage
return $relative_date.' ago';
}
+
+function age($dob,$owner_tz = '',$viewer_tz = '') {
+ if(strlen($dob) != 10)
+ return 0;
+ if(! $owner_tz)
+ $owner_tz = date_default_timezone_get();
+ if(! $viewer_tz)
+ $viewer_tz = date_default_timezone_get();
+
+ $birthdate = datetime_convert('UTC',$owner_tz,$dob . ' 00:00:00+00:00','Y-m-d');
+ list($year,$month,$day) = explode("-",$birthdate);
+ $year_diff = datetime_convert('UTC',$viewer_tz,'now','Y') - $year;
+ $curr_month = datetime_convert('UTC',$viewer_tz,'now','m');
+ $curr_day = datetime_convert('UTC',$viewer_tz,'now','d');
+
+ if(($curr_month < $month) || (($curr_month == $month) && ($curr_day < $day)))
+ $year_diff--;
+ return $year_diff;
+}