Last active
January 21, 2023 22:16
-
-
Save shiraliali/2cc4a64dcf8acd96d25d93842ae19386 to your computer and use it in GitHub Desktop.
PHP function for messure remaining days between two unix time format
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* messureSubscriptionDays | |
* Returns messured days based on unix time format. | |
* @param mixed $subscription | |
* @return void | |
* | |
*/ | |
function messureSubscriptionDays($subscription) | |
{ | |
$now = time(); // current time in unix format | |
$remainTimeUnix = $subscription - $now; // messure the difference of $now and passed unix time as $subscription parameter | |
$remainDays = $remainTimeUnix / 86400; // divide the difference by a day long in unix time format | |
return substr($remainDays, 0, 3); // add offset on float messured number by first 3 character. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment