Date Field Complete

This commit is contained in:
ultimatemember
2014-12-31 20:04:10 +02:00
parent 59431d3703
commit 1f2e7b54dd
12 changed files with 151 additions and 19 deletions
+16
View File
@@ -13,6 +13,22 @@ class UM_DateTime {
return current_time( $format );
}
/***
*** @Get age
***/
function get_age($then) {
$then_ts = strtotime($then);
$then_year = date('Y', $then_ts);
$age = date('Y') - $then_year;
if(strtotime('+' . $age . ' years', $then_ts) > time()) $age--;
if ( $age == 1 )
return sprintf(__('%s year old','ultimatemember'), $age );
if ( $age > 1 )
return sprintf(__('%s years old','ultimatemember'), $age );
if ( $age == 0 )
return __('Less than 1 year old','ultimatemember');
}
/***
*** @Reformat dates
***/