I have a credit card validity period with a month and a year only entering as a say string 08/17. How can I change this line in format to pass it toAuthorize.net
08/17
Authorize.net
$creditCard->setExpirationDate( "2017-08");
I tried to use strtotime(), but it gives me the current year
strtotime()
echo $date = date('Y-m', strtotime($ccInfo['exp_date']));
You should use date_create_from_formatinstead strtotimeto create your date:
date_create_from_format
strtotime
echo date_create_from_format('m/y', '08/17')->format('Y-m');
The function creates an object \DateTime, so you can call the format to get the desired format.
\DateTime
You can also write
$eventDate = DateTime::createFromFormat('m/y', '08/17'); echo date_format($eventDate, 'Y-m');
Source: https://habr.com/ru/post/1655150/More articles:What is the difference between types of development branches and type? - gitIncreasing the precision or scale of a column of a number in Oracle - oracleWooCommerce problem - returning integer portion of sizes for products - phpswift: как получить indexpath.row при нажатии кнопки в ячейке? - buttonWatch Microsoft PowerPoint in OSX - vbaSearch tables by ID using simple HTML DOM Parser - htmlIdiomatic Scala: displaying options depending on the condition - scalaAWS Cloud Rendering Template - Setting an Area in an S3 Bucket - amazon-s3How to find out the execution time of KDB requests - kdbGradle error: could not solve org.jacoco: org.jacoco.agent - javaAll Articles