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

Breadcrumb

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

function PdoStore::getCurrentTimestampStatement

Provides an SQL function to get the current timestamp regarding the current connection's driver.

File

vendor/symfony/lock/Store/PdoStore.php, line 220

Class

PdoStore
PdoStore is a PersistingStoreInterface implementation using a PDO connection.

Namespace

Symfony\Component\Lock\Store

Code

private function getCurrentTimestampStatement() : string {
    return match ($this->getDriver()) {    'mysql' => 'UNIX_TIMESTAMP()',
        'sqlite' => 'strftime(\'%s\',\'now\')',
        'pgsql' => 'CAST(EXTRACT(epoch FROM NOW()) AS INT)',
        'oci' => '(SYSDATE - TO_DATE(\'19700101\',\'yyyymmdd\'))*86400 - TO_NUMBER(SUBSTR(TZ_OFFSET(sessiontimezone), 1, 3))*3600',
        'sqlsrv' => 'DATEDIFF(s, \'1970-01-01\', GETUTCDATE())',
        default => (string) time(),
    
    };
}

API Navigation

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