Your year should be an offset since 1900. That's most probably the culprit.
Try:
licence_expiry_time_struct.tm_year = gtime_to / 10000 - 1900;
In general, when using mktime()
it's highly recommended to start with a valid tm
structure in the first place (i.e. by calling localtime()
) and then changing the fields.