The hexadecimal number system is often used to represent colors in a fairly interpretable format. But "hex" isn't a thing in itself. Your question is therefore ambiguous. What you want is probably this:
PHP код:
RGBAToARGB(color) { new alpha = color & 0xFF; return ((color >>> 8) | (alpha << 24)); }