Check data according to serial

-5

I have a question about filling out the month, according to the serial number filled in.

The logic is in the 4th and 5th digit of the license, which is a hexadecimal number

Example: 0AC 19 2F4B16EA6A5CE

  • The number 19 means it will expire on 01/30/2018
  • Number 1A means it will expire 2/28/2018
  • Number 1B means it will expire 3/30/2018

My question is the following, is it possible a php rule or some script that can fill out the month when inserting the license in the form field?

    
asked by anonymous 17.02.2017 / 17:14

1 answer

5

If you want to know the date, this is enough:

function VencimentoSerial($serial) {
   $vencto = strtotime( '2016-1-1 +'.hexdec(substr($serial, 3, 2)).' months last day');
   return gmdate( 'd/m/Y', $vencto);
}

See working at IDEONE .

    
17.02.2017 / 18:31