本文整理汇总了PHP中Carbon\Carbon::toIso8601String方法的典型用法代码示例。如果您正苦于以下问题:PHP Carbon::toIso8601String方法的具体用法?PHP Carbon::toIso8601String怎么用?PHP Carbon::toIso8601String使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Carbon\Carbon
的用法示例。
在下文中一共展示了Carbon::toIso8601String方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getTrialEndForUpdate
/**
* Get the trial end timestamp for a Conekta subscription update.
*
* @return int
*/
protected function getTrialEndForUpdate()
{
if ($this->skipTrial) {
return Carbon::now()->toIso8601String();
}
return $this->trialEnd ? $this->trialEnd->toIso8601String() : null;
}
示例2: __invoke
/**
* __invoke
*
* Summaries for methods should use 3rd person declarative rather
* than 2nd person imperative, beginning with a verb phrase.
*
* @param mixed $date DESCRIPTION
* @param mixed $attr DESCRIPTION
* @param mixed $format DESCRIPTION
*
* @return mixed
*
* @access public
*/
public function __invoke($date, $attr = [], $format = null)
{
$date = new Carbon($date);
$attr = array_merge_recursive($attr, ['datetime' => $date->toIso8601String()]);
$content = $format ? $date->format($format) : $date->toDayDateTimeString();
return parent::__invoke($content, $attr, $this->tag);
}
示例3: validateTimestamp
private function validateTimestamp($timestamp)
{
if ($timestamp instanceof Carbon) {
$carbon = $timestamp;
} else {
if ($timestamp instanceof DateTime) {
$carbon = Carbon::instance($timestamp);
} else {
if (is_string($timestamp) && strtotime($timestamp) !== false) {
$carbon = new Carbon($timestamp);
} else {
throw new \InvalidArgumentException('Invalid date/time format.');
}
}
}
$this->timestamp = $carbon->toIso8601String();
}
示例4: getCreatedAtAttribute
public function getCreatedAtAttribute($value)
{
$dt = new Carbon($value);
return $dt->toIso8601String();
}
示例5: createReminder
/**
* タスクにリマインダーを設定する
*
* @param array $task 1タスクを表す配列
* @param Carbon $date リマインダー設定日時
*/
private function createReminder($task, Carbon $date)
{
$newReminder['task_id'] = $task['id'];
$newReminder['date'] = $date->toIso8601String();
$url = 'a.wunderlist.com/api/v1/reminders';
$this->poster->post($url, $newReminder, $this->tokens);
}
示例6: getTimestampAttribute
public function getTimestampAttribute()
{
$date = new Carbon($this->attributes['timestamp'], 'Asia/Bangkok');
return $date->toIso8601String();
}
示例7: castAttribute
/**
* Cast an attribute from a PHP type.
*
* @param $castTypes
* @param $key
* @param $value
* @return mixed
* @internal param BaseModel $model
* @internal param $object
*/
private function castAttribute($castTypes, $key, $value)
{
if (!array_key_exists($key, $castTypes)) {
return $value;
}
$castType = $castTypes[$key];
if ($value && in_array($castType, ['date', 'datetime'])) {
$date = new Carbon($value);
switch ($castType) {
case 'date':
return $date->format('Y-m-d');
default:
return $date->toIso8601String();
}
}
return $value;
}