Hi all.
Apple sends "Feedback" results as a stream of
4 bytes time_t, the date and time
2 bytes length of the next field (for now, always 32)
32 bytes of binary, a token to be converted to hex for display
So I have this 38-byte result. My SQL database stores each user's record as the "TIMESTAMP" data type.
Can someone point me in the right direction for what I need to do with this 4-byte "time_t" in order to be able to compare it to the SQL "TIMESTAMP"?
This is of course for my PHP script. I have to see if the value in the "time_t" is earlier than what is in that user's record in my SQL database.
Thanks
time_t 4 bytes in a stream - evaluate in PHP?
Moderator: General Moderators
-
johnnylundy
- Forum Newbie
- Posts: 4
- Joined: Fri Sep 25, 2009 2:48 pm
Re: time_t 4 bytes in a stream - evaluate in PHP?
time_t is an integer, same thing that time gives you back... except for the representation.
Big-endian or little-endian for it? As in, if you get the value, then wait a second, and get the value again, does the first byte change or does the last byte change?
Big-endian or little-endian for it? As in, if you get the value, then wait a second, and get the value again, does the first byte change or does the last byte change?
-
johnnylundy
- Forum Newbie
- Posts: 4
- Joined: Fri Sep 25, 2009 2:48 pm
Re: time_t 4 bytes in a stream - evaluate in PHP?
Thanks for the reply.tasairis wrote:time_t is an integer, same thing that time gives you back... except for the representation.
Big-endian or little-endian for it? As in, if you get the value, then wait a second, and get the value again, does the first byte change or does the last byte change?
All of the stream is big endian. 4 byte time_t, 2 byte length, 32 byte token.
I think I can use unpack() to parse it out with the format
Code: Select all
$result = fread($apns, 38);
$array = unpack("NnH32", $result);Re: time_t 4 bytes in a stream - evaluate in PHP?
They're comparable as-is. Just numbers.
(And just "N" for the unpack format.)
(And just "N" for the unpack format.)
-
johnnylundy
- Forum Newbie
- Posts: 4
- Joined: Fri Sep 25, 2009 2:48 pm
Re: time_t 4 bytes in a stream - evaluate in PHP?
I don't need the lowercase "n" for the short? The stream is an integer, a short, and a 32-byte string.tasairis wrote:They're comparable as-is. Just numbers.
(And just "N" for the unpack format.)
Ah, so timestamps are just 32-bit integers like time_t?
-
johnnylundy
- Forum Newbie
- Posts: 4
- Joined: Fri Sep 25, 2009 2:48 pm
Re: time_t 4 bytes in a stream - evaluate in PHP?
OK - much appreciated!