Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. DateCaster.php

function DateCaster::castDateTime

File

vendor/symfony/var-dumper/Caster/DateCaster.php, line 27

Class

DateCaster
Casts DateTimeInterface related classes to array representation.

Namespace

Symfony\Component\VarDumper\Caster

Code

public static function castDateTime(\DateTimeInterface $d, array $a, Stub $stub, bool $isNested, int $filter) : array {
    $prefix = Caster::PREFIX_VIRTUAL;
    $location = $d->getTimezone() ? $d->getTimezone()
        ->getLocation() : null;
    $fromNow = (new \DateTimeImmutable())->diff($d);
    $title = $d->format('l, F j, Y') . "\n" . self::formatInterval($fromNow) . ' from now' . ($location ? $d->format('I') ? "\nDST On" : "\nDST Off" : '');
    unset($a[Caster::PREFIX_DYNAMIC . 'date'], $a[Caster::PREFIX_DYNAMIC . 'timezone'], $a[Caster::PREFIX_DYNAMIC . 'timezone_type']);
    $a[$prefix . 'date'] = new ConstStub(self::formatDateTime($d, $location ? ' e (P)' : ' P'), $title);
    $stub->class .= $d->format(' @U');
    return $a;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal