mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-07-11 18:56:10 +09:00
Date Field Complete
This commit is contained in:
@@ -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
|
||||
***/
|
||||
|
||||
Reference in New Issue
Block a user