碳间隔的访问间隔

问题描述 投票:0回答:1
CarbonInterval {#1680 ▼
  interval: + 00:07:36.0
  #tzName: null
  #localMonthsOverflow: null
  #localYearsOverflow: null
  #localStrictModeEnabled: null
  #localHumanDiffOptions: null
  #localToStringFormat: null
  #localSerializer: null
  #localMacros: null
  #localGenericMacros: null
  #localFormatFunction: null
  #localTranslator: null
  +"y": 0
  +"m": 0
  +"d": 0
  +"h": 0
  +"i": 0
  +"s": 456
  +"f": 0.0
  +"weekday": 0
  +"weekday_behavior": 0
  +"first_last_day_of": 0
  +"invert": 0
  +"days": false
  +"special_type": 0
  +"special_amount": 0
  +"have_weekday_relative": 0
  +"have_special_relative": 0
}

如何从此interval: + 00:07:36.0对象访问此CarbonPeriod值。

laravel php-carbon
1个回答
0
投票

[CarbonInterval具有一个称为cascade()的功能,它将相应地填充其他字段。

哪个将返回carbonInterval对象,如下所示。>>

 +"y": 0
 +"m": 0
 +"d": 0
 +"h": 0
 +"i": 7
 +"s": 36
 +"f": 0.0

然后我们可以访问那些属性,或者我们可以调用format('%H:%I:%s')以获取所需的值。

示例

$carbonInterval->cascade()->format('%H:%I:%s')
© www.soinside.com 2019 - 2024. All rights reserved.