You say that you need to compare the two time_t values, ultimately. But how do you get these values? If they are sent as strings, then Byron Whitlock's answer is believable if your machine supports getdate() . If they are already time_t , you can compare the time values. If you need to compare time_t , created locally, with a string, created remotely, then you fall between a rock and a solid place; you must somehow find out which ISO 8601 style is used when sending data.
Please note that ISO 8601 expects that the two systems exchanging information will agree with the designation they intend to use, and in particular that they will agree which fields can be omitted (if any) and whether punctuation will separate the fields, if you if you know the (one) format or you can configure your system to use the ISO 8601 format for each data source, the POSIX strptime() function can handle almost everything - although you need to know how your code will handle any undefined fields.
The name of the standard in full: "ISO 8601: 2004 Data elements and data exchange formats - Information exchange - Presentation of dates and times." Its section Β§3.7 of the Mutual Agreement states:
Some of the representations specified in this standard are allowed only by mutual agreement of the exchange partners. Such an agreement should ensure that the fields in which the representation is presented may not exist in order to retain other representations that cannot be clearly distinguished from the Agreed Representation.
source share