I\'ve set up a C++ server/client environment, and am trying to send a time_t value from the server to the client (an useful thing in any server). But I\'m coming accross a heada
You could send a textual representation produced by strftime in combination with gmtime
. The representation would be a bit larger than a binary representation, but not huge. E.g., the format string "%Y%j%H%M%S"
produces a 13-byte representation of a moment in time (excluding a NUL character).
EDIT: forget about my previous advice to use ctime
; that uses localtime and would therefore only work if client and server are in the same timezone. And apparently, asctime
is unsafe, so use strftime
.