从未来一天获取日期和 Carbon 中的指定日期?

Get date from coming day and specified date in Carbon?

在 Carbon 中,我可以做到

Carbon::parse("This Sunday"); // This gives me coming date for Sunday

但我想获取像 get coming date of Sunday after 2018-01-01 这样的一天的日期。有没有可能实现这样的目标?

你可以

$sunday = Carbon::parse("This Sunday");
$sunday->next(Carbon::SUNDAY);

Docs

是的,你可以这样写。

Carbon::parse('first sunday of January 2018')

文档在这里http://carbon.nesbot.com/docs/

您可以通过

轻松实现
Carbon::parse("2018-01-01")->modify("next Sunday");

或使用 next() 可能更快

Carbon::parse("2018-01-01")->next(Carbon::SUNDAY);

你可以这样做: 正如官方所说documentation

$sunday = Carbon::parse("This Sunday"); //you are able to retrieve this currently

$nextSunday = $sunday->addWeek();