Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Sanix-Darker/b5d36c1e27f99ec8cb47b3b4231ee474 to your computer and use it in GitHub Desktop.
Save Sanix-Darker/b5d36c1e27f99ec8cb47b3b4231ee474 to your computer and use it in GitHub Desktop.
[PHP] Convert Days to Year,Month,Day Format
<?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