Carbon php 日期时间数学
Carbon php date time math
我知道何时在 UTC 中创建帐户。如果帐户在太平洋标准时间第二天凌晨 2 点之前被取消,则需要删除该帐户,否则直到稍后才会删除。我无法想出在 Carbon 中使用的实际语句。例如:
$account->getAttribute('created_at');
returns
Illuminate\Support\Carbon @1597790786 {#3432
date: 2020-08-18 22:46:26.0 UTC (+00:00),
}
因此我需要知道 now() 是否 >= 2020-08-19 02:00:00.0 PDT/PST.
我应该怎么做?
切换您的时区日期以考虑 "tomorrow 2am"
然后 re-switch UTC 进行比较:
$cancellation = $account->getAttribute('cancelled_at');
$creation = $account->getAttribute('created_at');
if ($cancellation < $creation->tz('PST')->modify('tomorrow 2am')->utc()) {
// remove
}
我知道何时在 UTC 中创建帐户。如果帐户在太平洋标准时间第二天凌晨 2 点之前被取消,则需要删除该帐户,否则直到稍后才会删除。我无法想出在 Carbon 中使用的实际语句。例如:
$account->getAttribute('created_at');
returns
Illuminate\Support\Carbon @1597790786 {#3432
date: 2020-08-18 22:46:26.0 UTC (+00:00),
}
因此我需要知道 now() 是否 >= 2020-08-19 02:00:00.0 PDT/PST.
我应该怎么做?
切换您的时区日期以考虑 "tomorrow 2am"
然后 re-switch UTC 进行比较:
$cancellation = $account->getAttribute('cancelled_at');
$creation = $account->getAttribute('created_at');
if ($cancellation < $creation->tz('PST')->modify('tomorrow 2am')->utc()) {
// remove
}