Originally posted by Linh
The above Bash script convert today 's date to a number.
1) Are the year, month, date, hour, minutes, seconds
and thousands of a second involved in this conversion ?
No, just seconds. But you can get the nano
seconds part of the time since the epoch with: date "+%N"
Or in C using the gettimeofday() function.
2) What is the mathematical formular for this conversion ?
None actually. It's the other way around: The system (kernel) base format for the current time is
in "number of seconds since the epoch". All other time formats are conversions from this.
3) What is the C built-in function for the above Bash
That is the time() function. This example below does the same as: date "+%s".
printf("%ld\n", (long int)time(NULL));