Php get how many days and hours left from a date

前端 未结 6 1413
一生所求
一生所求 2020-12-03 11:47

I have a created_at date saved liked this \"2011-09-23 19:10:18\" And I want to get the days and hours left until the date is reached. How do I do that? and column name in

6条回答
  •  余生分开走
    2020-12-03 12:24

    This should seed your endeavor.

    getdate(strtotime("2011-09-23 19:10:18"))
    

    Full conversion:

    $seconds = strtotime("2011-09-23 19:10:18") - time();
    
    $days = floor($seconds / 86400);
    $seconds %= 86400;
    
    $hours = floor($seconds / 3600);
    $seconds %= 3600;
    
    $minutes = floor($seconds / 60);
    $seconds %= 60;
    
    
    echo "$days days and $hours hours and $minutes minutes and $seconds seconds";
    

提交回复
热议问题