php - How to get days and months number from a given days -
i'm going write function print number of days left between 2 dates. tell months , days left. example:
45 days = 1month, 15 days 65 days = 2months, 5 days 10 days = 10 days
so tried:
<? $days=50; if($days>"31"){ $time=$days/30; } echo $time;//1.67 month ?>
according code above. expect result like:
1 month, 20 days
could guys please suggest.
try:
$days = 50; if ($days > 31){ $month = floor($days/30); // homecoming lowest whole integer $days = $days % 30; // calculate left days } echo $month . " => " . $days; // output `1 => 20`
php get days
No comments:
Post a Comment