PHP, Get tomorrows date from date

后端 未结 11 1809
不思量自难忘°
不思量自难忘° 2020-11-30 02:54

I have a PHP date in the form of 2013-01-22 and I want to get tomorrows date in the same format, so for example 2013-01-23.

How is this pos

相关标签:
11条回答
  • 2020-11-30 03:29

    Use DateTime:

    To get tomorrow from now :

    $d = new DateTime('+1day');
    $tomorrow = $d->format('d/m/Y h.i.s');
    echo $tomorrow;
    

    Results : 28/06/2017 08.13.20

    To get tomorrow from a date :

    $d = new DateTime('2017/06/10 08.16.35 +1day')
    $tomorrow = $d->format('d/m/Y h.i.s');
    echo $tomorrow;
    

    Results : 11/06/2017 08.16.35

    Hope it helps!

    0 讨论(0)
  • 2020-11-30 03:31
    $date = '2013-01-22';
    $time = strtotime($date) + 86400;
    echo date('Y-m-d', $time);
    

    Where 86400 is the # of seconds in a day.

    0 讨论(0)
  • 2020-11-30 03:32
     $tomorrow = date("Y-m-d", strtotime('tomorrow'));
    

    or

      $tomorrow = date("Y-m-d", strtotime("+1 day"));
    

    Help Link: STRTOTIME()

    0 讨论(0)
  • 2020-11-30 03:32

    here's working function

    function plus_one_day($date){
     $date2 = formatDate4db($date);
     $date1 = str_replace('-', '/', $date2);
     $tomorrow = date('Y-m-d',strtotime($date1 . "+1 days"));
     return $tomorrow; }
    
    0 讨论(0)
  • 2020-11-30 03:35
    <? php 
    
    //1 Day = 24*60*60 = 86400
    
    echo date("d-m-Y", time()+86400); 
    
    ?>
    
    0 讨论(0)
提交回复
热议问题