original_string: public static function date2timestamp($date, $format = null)
      {
          $config = Grav::instance()['config'];
          $dateformat = $format ?: $config->get('system.pages.dateformat.default');
  
          // try to use DateTime and default format
          if ($dateformat) {
              $datetime = \DateTime::createFromFormat($dateformat, $date);
          } else {
              $datetime = new \DateTime($date);
          }
  
          // fallback to strtotime() if DateTime approach failed
          if ($datetime !== false) {
              return $datetime->getTimestamp();
          }
  
          return strtotime($date);
      }
code: public static function date2timestamp($date, $format = null)
      {
          $config = Grav::instance()['config'];
          $dateformat = $format ?: $config->get('system.pages.dateformat.default');
  
          // try to use DateTime and default format
          if ($dateformat) {
              $datetime = \DateTime::createFromFormat($dateformat, $date);
          } else {
              $datetime = new \DateTime($date);
          }
  
          // fallback to strtotime() if DateTime approach failed
          if ($datetime !== false) {
              return $datetime->getTimestamp();
          }
  
          return strtotime($date);
      }
code_tokens: public static function date2timestamp ( $ date , $ format = null ) { $ config = Grav :: instance ( ) [ 'config' ] ; $ dateformat = $ format ? : $ config -> get ( 'system.pages.dateformat.default' ) ; // try to use DateTime and default format if ( $ dateformat ) { $ datetime = \ DateTime :: createFromFormat ( $ dateformat , $ date ) ; } else { $ datetime = new \ DateTime ( $ date ) ; } // fallback to strtotime() if DateTime approach failed if ( $ datetime !== false ) { return $ datetime -> getTimestamp ( ) ; } return strtotime ( $ date ) ; }
docstring: Get the timestamp of a date
  
  @param string $date a String expressed in the system.pages.dateformat.default format, with fallback to a
  strtotime argument
  @param string $format a date format to use if possible
  @return int the timestamp
docstring_tokens: Get the timestamp of a date