In our HR system, we want to calculate the number of years the employee has served the company.
What we have is the joining date in TIMESTAMP
column.
What I am doing is:
$timeNow = time(); // current time
$joinDate = strtotime($users->fields['date_of_joining']); // from database
$servicePeriod = $timeNow - $joinDate; // in seconds
$servicePeriod = $servicePeriod / 31570560; // in years
But will this take the leap years into consideration? If an employee joined in Feb 27
of a leap year and if we check the status next year by March 1
, he should still be reported as served for 1 year
and not 1 year and 1 day
.
Any ideas on this? Thanks.