Last active
May 1, 2022 08:31
-
-
Save Sanix-Darker/b5d36c1e27f99ec8cb47b3b4231ee474 to your computer and use it in GitHub Desktop.
[PHP] Convert Days to Year,Month,Day Format
This file contains hidden or 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
| <?php | |
| $convert = '5000'; // days you want to convert | |
| $years = ($convert / 365) ; // days / 365 days | |
| $years = floor($years); // Remove all decimals | |
| $month = ($convert % 365) / 30.5; // I choose 30.5 for Month (30,31) ;) | |
| $month = floor($month); // Remove all decimals | |
| $days = ($convert % 365) % 30.5; // the rest of days | |
| // Echo all information set | |
| echo 'DAYS RECEIVE : '.$convert.' days<br>'; | |
| echo $years.' years - '.$month.' month - '.$days.' days'; | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment