Convert Electronic Invoice Date and Time - Javascript

Asked

Viewed 79 times

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 documentation of the recipe:

The value shall correspond to the hexadecimal box conversion low value in UTC standard with mask.

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

dhEmi=323031382D30372D32345431323A31323A33352D30333A3030

I wonder how I can convert this value to a valid datetime in javascript

1 answer

2


function 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;
   }

Browser other questions tagged

You are not signed in. Login or sign up in order to post.