Why the results of the command 'date -u' command 'date' faster than the result of 25 seconds in linux(centos 5.1)? -
in centos release 5.10, results of command 'date -u' command 'date' faster result of 25 seconds.
here result:
[a@mg11za1 b]$ lsb_release -a lsb version: :core-4.0-amd64:core-4.0-ia32:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0- ia32:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-ia32:printing-4.0-noarch distributor id: centos description: centos release 5.10 (final) release: 5.10 codename: final [a@mg11za1 b]$ uname -a linux mg11za1 2.6.18-371.el5 #1 smp tue oct 1 08:35:08 edt 2013 x86_64 x86_64 x86_64 gnu/linux [a@mg11za1 b]$ date && date -u && /usr/sbin/hwclock --show fri jun 26 17:47:42 cst 2015 fri jun 26 09:48:07 utc 2015 fri 26 jun 2015 05:47:18 pm cst -0.235359 seconds
and result of following code not right
#include <time.h> #include <stdio.h> int main(int argc, char** argv) { time_t = time(null); struct tm today; localtime_r(&now, &today); printf( "seconds:%d\n" "minutes:%d\n" "hours:%d\n" "day of month:%d\n" "month:%d\n" "year:%d\n" "day of week:%d\n" "day in year:%d\n" "daylight saving time:%d\n" ,today.tm_sec ,today.tm_min ,today.tm_hour ,today.tm_mday ,today.tm_mon ,today.tm_year ,today.tm_wday ,today.tm_yday ,today.tm_isdst); time_t weekstart = - today.tm_wday * 24*60*60; printf("weekstart:%u\n", (unsigned int)weekstart); struct tm start; localtime_r(&weekstart,&start); start.tm_hour = 0; start.tm_min = 0; start.tm_sec = 0; unsigned int version = mktime(&start); printf("version:%u\n", version); return 0; }
the result of above code is:
seconds:53 minutes:54 hours:17 day of month:26 month:5 year:115 day of week:5 day in year:176 daylight saving time:0 weekstart:1434880518 version:1434816025
the version should 1434816000 not 1434816025, (now 2015-06-26).
thanks person answer
at guess, timezone right/prc
, timezone explicitly adjusted leap seconds. can see difference here:
this right/prc
, not apply (current) 25 seconds time being reported:
env tz=right/prc date fri jun 26 19:13:18 cst 2015
this prc
, has applied (current) 25 seconds time being reported:
env tz=prc date fri jun 26 19:13:43 cst 2015
this utc
, same timezone reported date -u
:
env tz=utc date fri jun 26 11:13:43 utc 2015
finally there right/utc
, time without (current) 25 second adjustment:
env tz=right/utc date fri jun 26 11:13:18 utc 2015
you should not using right/
timezones general use - not match reported time producers/consumers of time.
Comments
Post a Comment