PHP, Get tomorrows date from date

后端 未结 11 1861
不思量自难忘°
不思量自难忘° 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!

提交回复
热议问题