You are here

public static function CreditCard::calculateExpirationTimestamp in Commerce Core 8.2

Calculates the unix timestamp for a credit card expiration date.

Parameters

string $month: The 1 or 2-digit numeric representation of the month, i.e. 1, 6, 12.

string $year: The 4-digit numeric representation of the year, i.e. 2010.

Return value

int The expiration date as a unix timestamp.

4 calls to CreditCard::calculateExpirationTimestamp()
CreditCardTest::testCalculateExpirationTimestamp in modules/payment/tests/src/Unit/CreditCardTest.php
@covers ::calculateExpirationTimestamp
Onsite::createPaymentMethod in modules/payment_example/src/Plugin/Commerce/PaymentGateway/Onsite.php
Creates a payment method with the given payment details.
PaymentMethodEditForm::submitConfigurationForm in modules/payment/src/PluginForm/PaymentMethodEditForm.php
Form submission handler.
StoredOffsiteRedirect::createPaymentMethod in modules/payment_example/src/Plugin/Commerce/PaymentGateway/StoredOffsiteRedirect.php

File

modules/payment/src/CreditCard.php, line 247

Class

CreditCard
Provides logic for listing card types and validating card details.

Namespace

Drupal\commerce_payment

Code

public static function calculateExpirationTimestamp(string $month, string $year) : int {

  // Credit cards expire on the last day of the month.
  $month_start = strtotime($year . '-' . $month . '-01');
  $last_day = date('t', $month_start);
  return mktime(23, 59, 59, $month, $last_day, $year);
}