The subroutines in <time.h>are cross-platform and in fact should be available to comply with ISO C implementations. Use timeto get the elapsed time since 1970 and localtimeor gmtimeto break this down in a matter of hours, minutes and seconds.
You should not worry about struct tmusing too much memory to store unnecessary fields unless you program extremely memory-limited devices, in which case you are probably not looking for a cross-platform solution.
source
share