Convert Date and Time of Electronic Invoice - Javascript

1

The electronic invoice generates a qr-code from a url. This url has several parameters, one of them is the date and time of the issue, which according to the revenue documentation reads:

  

The value should match the conversion to hexadecimal in box   low value in the UTC default with mask.

In a url that I have, this field has 50 bytes, as below:

dhEmi=323031382D30372D32345431323A31323A33352D30333A3030

I would like to know how can I convert this value to a valid datetime in javascript

    
asked by anonymous 30.07.2018 / 16:18

1 answer

2
    hex2date(hexx) {
       const hex = hexx.toString();
       let datestr = '';
       for (let i = 0; (i < hex.length && hex.substr(i, 2) !== '00'); i += 2)
           datestr += String.fromCharCode(parseInt(hex.substr(i, 2), 16));
       return datestr;
   }
    
30.07.2018 / 16:40