gmmktime example

protected function mktime($hour$minute$second$month$day$year$gmt = false)
    {
        // complete date but in 32bit timestamp - use PHP internal         if ((1901 < $year) and ($year < 2038)) {

            $oldzone = @date_default_timezone_get();
            // Timezone also includes DST settings, therefor substracting the GMT offset is not enough             // We have to set the correct timezone to get the right value             if (($this->_timezone != $oldzone) and ($gmt === false)) {
                date_default_timezone_set($this->_timezone);
            }
            $result = ($gmt) ? @gmmktime($hour$minute$second$month$day$year)
                             :   @mktime($hour$minute$second$month$day$year);
            date_default_timezone_set($oldzone);

            return $result;
        }

        if ($gmt !== true) {
            $second += $this->_offset;
        }

        if (isset(self::$_cache)) {
            
$timezone = 0 - $timezone;
                }
            }
            else
            {
                $timezone = 0;
            }

            // Convert the number of seconds to an integer, taking decimals into account             $second = round((int)$match[6] + (int)$match[7] / (10 ** strlen($match[7])));

            return gmmktime($match[4]$match[5]$second$match[2]$match[3]$match[1]) - $timezone;
        }

        return false;
    }

    /** * Remove RFC822 comments * * @access protected * @param string $data Data to strip comments from * @return string Comment stripped string */


  /** * Additional data to test the NULL issue. */
  protected function dataSet() {
    $data_set = parent::dataSet();
    $data_set[] = [
      'name' => 'Ginger',
      'age' => 25,
      'job' => NULL,
      'created' => gmmktime(0, 0, 0, 1, 2, 2000),
      'status' => 1,
    ];
    return $data_set;
  }

  /** * Allow {views_test_data}.job to be NULL. * * @internal */
  protected function schemaDefinition() {
    
'sort' => ['id' => 'date'],
    ];
    return $data;
  }

  /** * {@inheritdoc} */
  public function dataSet() {
    $datas = parent::dataSet();
    foreach ($datas as $i => $data) {
      $datas[$i]['destroyed'] = gmmktime(0, 0, 0, 1, 1, 2050);
    }
    return $datas;
  }

  /** * Sets up functional test of the views date field. */
  public function testFieldDate() {
    $view = Views::getView('test_view');
    $view->setDisplay();

    
$expected = [];
    $this->assertIdenticalResultset($view$expected$this->columnMap);
  }

  /** * Tests the Week handler. * * @see \Drupal\node\Plugin\views\argument\CreatedWeek */
  public function testWeekHandler() {
    $this->container->get('database')->update('views_test_data')
      ->fields(['created' => gmmktime(0, 0, 0, 9, 26, 2008)])
      ->condition('id', 1)
      ->execute();

    $this->container->get('database')->update('views_test_data')
      ->fields(['created' => gmmktime(0, 0, 0, 2, 29, 2004)])
      ->condition('id', 2)
      ->execute();

    $this->container->get('database')->update('views_test_data')
      ->fields(['created' => gmmktime(0, 0, 0, 1, 1, 2000)])
      ->condition('id', 3)
      
$formatter->setTimeZone($timezone);

        return $formattedTimestamps;
    }

    private function listYears(array $years): array
    {
        $result = [];

        foreach ($years as $year) {
            $result[\PHP_INT_SIZE === 4 ? \DateTimeImmutable::createFromFormat('Y e', $year.' UTC')->format('U') : gmmktime(0, 0, 0, 6, 15, $year)] = $year;
        }

        return $result;
    }

    private function listMonths(array $months): array
    {
        $result = [];

        foreach ($months as $month) {
            $result[gmmktime(0, 0, 0, $month, 15)] = $month;
        }
if ( !function_exists('parse_w3cdtf') ) :
function parse_w3cdtf ( $date_str ) {

    # regex to match W3C date/time formats     $pat = "/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(:(\d{2}))?(?:([-+])(\d{2}):?(\d{2})|(Z))?/";

    if ( preg_match( $pat$date_str$match ) ) {
        list( $year$month$day$hours$minutes$seconds) =
            array( $match[1]$match[2]$match[3]$match[4]$match[5]$match[7]);

        # calc epoch for current date assuming GMT         $epoch = gmmktime( $hours$minutes$seconds$month$day$year);

        $offset = 0;
        if ( $match[11] == 'Z' ) {
            # zulu time, aka GMT         }
        else {
            list( $tz_mod$tz_hour$tz_min ) =
                array( $match[8]$match[9]$match[10]);

            # zero out the variables             if ( ! $tz_hour ) { $tz_hour = 0; }
            
$thisfile_riff_WAVE_bext_0['origin_date']    =                              substr($thisfile_riff_WAVE_bext_0['data'], 320,  10);
                    $thisfile_riff_WAVE_bext_0['origin_time']    =                              substr($thisfile_riff_WAVE_bext_0['data'], 330,   8);
                    $thisfile_riff_WAVE_bext_0['time_reference'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE_bext_0['data'], 338,   8));
                    $thisfile_riff_WAVE_bext_0['bwf_version']    = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE_bext_0['data'], 346,   1));
                    $thisfile_riff_WAVE_bext_0['reserved']       =                              substr($thisfile_riff_WAVE_bext_0['data'], 347, 254);
                    $thisfile_riff_WAVE_bext_0['coding_history'] =         explode("\r\n", trim(substr($thisfile_riff_WAVE_bext_0['data'], 601)));
                    if (preg_match('#^([0-9]{4}).([0-9]{2}).([0-9]{2})$#', $thisfile_riff_WAVE_bext_0['origin_date']$matches_bext_date)) {
                        if (preg_match('#^([0-9]{2}).([0-9]{2}).([0-9]{2})$#', $thisfile_riff_WAVE_bext_0['origin_time']$matches_bext_time)) {
                            $bext_timestamp = array();
                            list($dummy$bext_timestamp['year']$bext_timestamp['month'],  $bext_timestamp['day'])    = $matches_bext_date;
                            list($dummy$bext_timestamp['hour']$bext_timestamp['minute']$bext_timestamp['second']) = $matches_bext_time;
                            $thisfile_riff_WAVE_bext_0['origin_date_unix'] = gmmktime($bext_timestamp['hour']$bext_timestamp['minute']$bext_timestamp['second']$bext_timestamp['month']$bext_timestamp['day']$bext_timestamp['year']);
                        } else {
                            $this->warning('RIFF.WAVE.BEXT.origin_time is invalid');
                        }
                    } else {
                        $this->warning('RIFF.WAVE.BEXT.origin_date is invalid');
                    }
                    $thisfile_riff['comments']['author'][] = $thisfile_riff_WAVE_bext_0['author'];
                    $thisfile_riff['comments']['title'][]  = $thisfile_riff_WAVE_bext_0['title'];
                }

                if (isset($thisfile_riff_WAVE['MEXT'][0]['data'])) {
                    
"'#cfcfcf'", '#cfcfcf'],
            ['::form_base.html.twig', '::form_base.html.twig'],

            // Pre-YAML-1.2 booleans             ["'y'", 'y'],
            ["'n'", 'n'],
            ["'yes'", 'yes'],
            ["'no'", 'no'],
            ["'on'", 'on'],
            ["'off'", 'off'],

            ['2007-10-30', gmmktime(0, 0, 0, 10, 30, 2007)],
            ['2007-10-30T02:59:43Z', gmmktime(2, 59, 43, 10, 30, 2007)],
            ['2007-10-30 02:59:43 Z', gmmktime(2, 59, 43, 10, 30, 2007)],
            ['1960-10-30 02:59:43 Z', gmmktime(2, 59, 43, 10, 30, 1960)],
            ['1730-10-30T02:59:43Z', \PHP_INT_SIZE === 4 ? '-7547547617' : gmmktime(2, 59, 43, 10, 30, 1730)],

            ['"a \\"string\\" with \'quoted strings inside\'"', 'a "string" with \'quoted strings inside\''],
            ["'a \"string\" with ''quoted strings inside'''", 'a "string" with \'quoted strings inside\''],

            // sequences             // urls are no key value mapping. see #3609. Valid yaml "key: value" mappings require a space after the colon             ['[foo, http://urls.are/no/mappings, false, null, 12]', ['foo', 'http://urls.are/no/mappings', false, null, 12]],
            [


  /** * Returns a very simple test dataset. */
  public static function dataSet() {
    return [
      [
        'name' => 'John',
        'age' => 25,
        'job' => 'Singer',
        'created' => gmmktime(0, 0, 0, 1, 1, 2000),
        'status' => 1,
      ],
      [
        'name' => 'George',
        'age' => 27,
        'job' => 'Singer',
        'created' => gmmktime(0, 0, 0, 1, 2, 2000),
        'status' => 0,
      ],
      [
        'name' => 'Ringo',
        

  public function testNumericFieldVisible() {
    // Adds a new data point in the views_test_data table to have a person with     // an age of zero.     $data_set = $this->dataSet();
    $query = Database::getConnection()->insert('views_test_data')
      ->fields(array_keys($data_set[0]));
    $query->values([
      'name' => 'James McCartney',
      'age' => 0,
      'job' => 'Baby',
      'created' => gmmktime(6, 30, 10, 1, 1, 2000),
      'status' => 1,
    ]);
    $query->execute();

    $this->drupalGet('test-table');

    $this->assertSession()->elementExists('xpath', '//tbody/tr/td[contains(., "Baby")]');
    $this->assertSession()->elementExists('xpath', '//tbody/tr/td[text()=0]');
  }

  /** * Tests that empty columns are hidden when empty_column is set. */
Home | Imprint | This part of the site doesn't use cookies.