i am working on an access site, paying members will get exactly 3 months access period to the site. the issue therefore is how to calculate an exact 3 month date period.
i.e, some months are 28 days, others are 31 days; normal years is 365 but lunar year is 354 days.
i was thinking of converting the date to a UNIX timestamps and then calculating 3 months in seconds. But i am not sure whether this is the most efficient and accurate way to do it.
below is my proposal , i would really appreciate some advice on it;
timestamp when the clocks starts
$UNIXtimeStampNow = new \DateTime("now"))->format('U')
calculating 3 months from date:
$numberDaysInMonth = 30.41 = 365/ 12 //number of days in months
$numberSecondsInDay = 86400; //number seconds in a day
$secondsIn3Months = ($numberDaysInMonth * $numberSecondsInDay) * 3 //number seconds in 3 months
new \DateTime("$secondsIn3Months"); //convert back to date object
like i said, this is the best i came up with, but i suspect that its not accurate.
would really appropriate some advice