how to get date of yesterday using php?

前端 未结 9 1635
悲&欢浪女
悲&欢浪女 2021-01-30 04:51

I want to get the yesterday date using specific date format in php this is the format:

$today = date(\"d.m.Y\"); //15.04.2013

Is it possible?

9条回答
  •  灰色年华
    2021-01-30 05:26

    You can also do this using Carbon library:

    Carbon::yesterday()->format('d.m.Y');         // '26.03.2019'
    

    In other formats:

    Carbon::yesterday()->toDateString();          // '2019-03-26'
    Carbon::yesterday()->toDateTimeString();      // '2019-03-26 00:00:00'
    
    Carbon::yesterday()->toFormattedDateString(); // 'Mar 26, 2019'
    Carbon::yesterday()->toDayDateTimeString();   // 'Tue, Mar 26, 2019 12:00 AM'
    

提交回复
热议问题