You are here

public static function CommercePaymentCreditCard::calculateExpirationTimestamp in Commerce Core 7

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.

1 call to CommercePaymentCreditCard::calculateExpirationTimestamp()
CommercePaymentCreditCardTest::testCalculateExpirationTimestamp in modules/payment/tests/commerce_payment_credit_card.test
@covers ::calculateExpirationTimestamp

File

modules/payment/includes/commerce_payment.credit_card.inc, line 634
Credit-card helper functions for Drupal commerce.

Class

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

Code

public static function calculateExpirationTimestamp($month, $year) {

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