The write code is a little essential - first it sends the least significant byte.
Your read code expects a large endian - it takes a null byte and shifts it by 24 bits.
Please note that in no case does the code depend on the local limb of the computer - the written code does not depend on it, it simply does not agree with each other.
Try this instead:
mypkt.dateTime = ((socket_buf[0] << 0) + (socket_buf[1] << 8) + (socket_buf[2] << 16) + ((uint32_t)socket_buf[3] << 24));
Actuation is necessary (but only in the last shift), because 0x80 - 0xff will be converted to signed int and undefined, which happens with bits that are shifted to a signed bit (thanks @Lundin)
NB: 16711840 is not the "current" date-time value in Unix, depending on which argument you use to represent it. You may have other problems elsewhere.
source share