{"id":61761,"date":"2025-04-29T10:04:29","date_gmt":"2025-04-29T02:04:29","guid":{"rendered":"https:\/\/fwq.ai\/blog\/61761\/"},"modified":"2025-04-29T10:04:29","modified_gmt":"2025-04-29T02:04:29","slug":"linux%e4%b8%8b%e7%9a%84c%e8%af%ad%e8%a8%80%e6%9c%89%e6%97%b6%e9%97%b4%e5%87%bd%e6%95%b0%e5%90%97-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/61761\/","title":{"rendered":"linux\u4e0b\u7684c\u8bed\u8a00\u6709\u65f6\u95f4\u51fd\u6570\u5417"},"content":{"rendered":"<blockquote><p>\n  linux\u4e2d\u7684c\u8bed\u8a00\u6807\u51c6\u5e93\u63d0\u4f9b\u4e86\u4e00\u7ec4\u4e0e\u65f6\u95f4\u76f8\u5173\u7684\u51fd\u6570\uff0c\u7528\u4e8e\u5904\u7406\u65e5\u671f\u3001\u65f6\u95f4\u548c\u65f6\u95f4\u95f4\u9694\u7b49\u64cd\u4f5c\uff0c\u5176\u4e2d\u6700\u5e38\u7528\u7684\u65f6\u95f4\u51fd\u6570\u662ftime.h\u5934\u6587\u4ef6\u4e2d\u5b9a\u4e49\u7684\u51fd\u6570\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202307\/10\/2023071014591834383.jpg\" class=\"aligncenter\" title=\"linux\u4e0b\u7684c\u8bed\u8a00\u6709\u65f6\u95f4\u51fd\u6570\u5417\u63d2\u56fe\" alt=\"linux\u4e0b\u7684c\u8bed\u8a00\u6709\u65f6\u95f4\u51fd\u6570\u5417\u63d2\u56fe\" \/><\/p>\n<p>\u672c\u6559\u7a0b\u64cd\u4f5c\u7cfb\u7edf\uff1aLinux5.18.14\u7cfb\u7edf\u3001Dell G3\u7535\u8111\u3002<\/p>\n<p>Linux\u4e2d\u7684C\u8bed\u8a00\u6807\u51c6\u5e93\u63d0\u4f9b\u4e86\u4e00\u7ec4\u4e0e\u65f6\u95f4\u76f8\u5173\u7684\u51fd\u6570\uff0c\u7528\u4e8e\u5904\u7406\u65e5\u671f\u3001\u65f6\u95f4\u548c\u65f6\u95f4\u95f4\u9694\u7b49\u64cd\u4f5c\u3002\u5176\u4e2d\u6700\u5e38\u7528\u7684\u65f6\u95f4\u51fd\u6570\u662ftime.h\u5934\u6587\u4ef6\u4e2d\u5b9a\u4e49\u7684\u51fd\u6570\u3002<\/p>\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u7528\u7684\u65f6\u95f4\u51fd\u6570\uff1a<\/p>\n<ul>\n<li>\n<p>time()\uff1a\u8fd4\u56de\u81ea1970\u5e741\u67081\u65e5\u4ee5\u6765\u7ecf\u8fc7\u7684\u79d2\u6570\uff0c\u7528\u4e8e\u8ba1\u7b97\u7cfb\u7edf\u7684\u5f53\u524d\u65f6\u95f4\u3002<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<\/li>\n<li>\n<p>localtime()\uff1a\u5c06\u65f6\u95f4\u6233\u8f6c\u6362\u4e3a\u672c\u5730\u65f6\u95f4\u7684\u7ed3\u6784\u4f53\u3002<\/p>\n<\/li>\n<li>\n<p>gmtime()\uff1a\u5c06\u65f6\u95f4\u6233\u8f6c\u6362\u4e3aUTC\u65f6\u95f4\u7684\u7ed3\u6784\u4f53\u3002<\/p>\n<\/li>\n<li>\n<p>strftime()\uff1a\u5c06\u65f6\u95f4\u6309\u7167\u6307\u5b9a\u683c\u5f0f\u683c\u5f0f\u5316\u4e3a\u5b57\u7b26\u4e32\u3002<\/p>\n<\/li>\n<li>\n<p>strptime()\uff1a\u4ece\u5b57\u7b26\u4e32\u89e3\u6790\u65f6\u95f4\uff0c\u5e76\u4ee5\u7ed3\u6784\u4f53\u5f62\u5f0f\u5b58\u50a8\u3002<\/p>\n<\/li>\n<li>\n<p>difftime()\uff1a\u8ba1\u7b97\u4e24\u4e2a\u65f6\u95f4\u4e4b\u95f4\u7684\u5dee\u503c\uff08\u79d2\uff09\u3002<\/p>\n<\/li>\n<li>\n<p>mktime()\uff1a\u5c06\u65f6\u95f4\u7ed3\u6784\u4f53\u8f6c\u6362\u4e3a\u65f6\u95f4\u6233\u3002<\/p>\n<\/li>\n<li>\n<p>ctime()\uff1a\u5c06\u65f6\u95f4\u6233\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32\uff0c\u8868\u793a\u4e3a\u672c\u5730\u65f6\u95f4\u3002<\/p>\n<\/li>\n<li>\n<p>asctime()\uff1a\u5c06\u65f6\u95f4\u7ed3\u6784\u4f53\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32\uff0c\u8868\u793a\u4e3a\u672c\u5730\u65f6\u95f4\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u8fd9\u4e9b\u51fd\u6570\u63d0\u4f9b\u4e86\u5728C\u7a0b\u5e8f\u4e2d\u5904\u7406\u65f6\u95f4\u548c\u65e5\u671f\u7684\u80fd\u529b\uff0c\u8ba9\u4f60\u53ef\u4ee5\u83b7\u53d6\u5f53\u524d\u65f6\u95f4\u3001\u8fdb\u884c\u65f6\u95f4\u7684\u8f6c\u6362\u3001\u683c\u5f0f\u5316\u8f93\u51fa\u7b49\u64cd\u4f5c\u3002<\/p>\n<p>\u8981\u4f7f\u7528\u8fd9\u4e9b\u65f6\u95f4\u51fd\u6570\uff0c\u4f60\u9700\u8981\u5305\u542btime.h\u5934\u6587\u4ef6\uff0c\u5e76\u94fe\u63a5\u5bf9\u5e94\u7684\u5e93\uff08\u901a\u5e38\u662flibrt.so\uff09\u3002<\/p>\n<p>\u8bf7\u6ce8\u610f\uff0c\u4e0d\u540c\u7684\u64cd\u4f5c\u7cfb\u7edf\u53ef\u80fd\u4f1a\u6709\u6240\u5dee\u5f02\uff0c\u6240\u4ee5\u5728\u4f7f\u7528\u65f6\u5efa\u8bae\u67e5\u9605\u76f8\u5173\u7684\u6587\u6863\u6216\u624b\u518c\u4ee5\u83b7\u53d6\u51c6\u786e\u7684\u51fd\u6570\u5b9a\u4e49\u548c\u4f7f\u7528\u65b9\u6cd5\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u4e0b\u7684c\u8bed\u8a00\u6709\u65f6\u95f4\u51fd\u6570\u5417\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8FDCServers\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>linux\u4e2d\u7684c\u8bed\u8a00\u6807\u51c6\u5e93\u63d0\u4f9b\u4e86\u4e00\u7ec4\u4e0e\u65f6\u95f4\u76f8\u5173\u7684\u51fd\u6570\uff0c\u7528\u4e8e\u5904\u7406\u65e5\u671f\u3001\u65f6\u95f4\u548c\u65f6\u95f4\u95f4\u9694\u7b49\u64cd\u4f5c\uff0c\u5176\u4e2d\u6700\u5e38\u7528\u7684\u65f6\u95f4\u51fd\u6570\u662ftime.h\u5934\u6587\u4ef6\u4e2d\u5b9a\u4e49\u7684\u51fd\u6570\u3002 \u672c\u6559\u7a0b\u64cd\u4f5c\u7cfb\u7edf\uff1aLinux5.18.14\u7cfb\u7edf\u3001Dell G3\u7535\u8111\u3002 Linux\u4e2d\u7684C\u8bed\u8a00\u6807\u51c6\u5e93\u63d0\u4f9b\u4e86\u4e00\u7ec4\u4e0e\u65f6\u95f4\u76f8\u5173\u7684\u51fd\u6570\uff0c\u7528\u4e8e\u5904\u7406\u65e5\u671f\u3001\u65f6\u95f4\u548c\u65f6\u95f4\u95f4\u9694\u7b49\u64cd\u4f5c\u3002\u5176\u4e2d\u6700\u5e38\u7528\u7684\u65f6\u95f4\u51fd\u6570\u662ftime.h\u5934\u6587\u4ef6\u4e2d\u5b9a\u4e49\u7684\u51fd\u6570\u3002 \u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u7528\u7684\u65f6\u95f4\u51fd\u6570\uff1a time()\uff1a\u8fd4\u56de\u81ea1970\u5e741\u67081\u65e5\u4ee5\u6765\u7ecf\u8fc7\u7684\u79d2\u6570\uff0c\u7528\u4e8e\u8ba1\u7b97\u7cfb\u7edf\u7684\u5f53\u524d\u65f6\u95f4\u3002 \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b localtime()\uff1a\u5c06\u65f6\u95f4\u6233\u8f6c\u6362\u4e3a\u672c\u5730\u65f6\u95f4\u7684\u7ed3\u6784\u4f53\u3002 gmtime()\uff1a\u5c06\u65f6\u95f4\u6233\u8f6c\u6362\u4e3aUTC\u65f6\u95f4\u7684\u7ed3\u6784\u4f53\u3002 strftime()\uff1a\u5c06\u65f6\u95f4\u6309\u7167\u6307\u5b9a\u683c\u5f0f\u683c\u5f0f\u5316\u4e3a\u5b57\u7b26\u4e32\u3002 strptime()\uff1a\u4ece\u5b57\u7b26\u4e32\u89e3\u6790\u65f6\u95f4\uff0c\u5e76\u4ee5\u7ed3\u6784\u4f53\u5f62\u5f0f\u5b58\u50a8\u3002 difftime()\uff1a\u8ba1\u7b97\u4e24\u4e2a\u65f6\u95f4\u4e4b\u95f4\u7684\u5dee\u503c\uff08\u79d2\uff09\u3002 mktime()\uff1a\u5c06\u65f6\u95f4\u7ed3\u6784\u4f53\u8f6c\u6362\u4e3a\u65f6\u95f4\u6233\u3002 ctime()\uff1a\u5c06\u65f6\u95f4\u6233\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32\uff0c\u8868\u793a\u4e3a\u672c\u5730\u65f6\u95f4\u3002 asctime()\uff1a\u5c06\u65f6\u95f4\u7ed3\u6784\u4f53\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32\uff0c\u8868\u793a\u4e3a\u672c\u5730\u65f6\u95f4\u3002 \u8fd9\u4e9b\u51fd\u6570\u63d0\u4f9b\u4e86\u5728C\u7a0b\u5e8f\u4e2d\u5904\u7406\u65f6\u95f4\u548c\u65e5\u671f\u7684\u80fd\u529b\uff0c\u8ba9\u4f60\u53ef\u4ee5\u83b7\u53d6\u5f53\u524d\u65f6\u95f4\u3001\u8fdb\u884c\u65f6\u95f4\u7684\u8f6c\u6362\u3001\u683c\u5f0f\u5316\u8f93\u51fa\u7b49\u64cd\u4f5c\u3002 \u8981\u4f7f\u7528\u8fd9\u4e9b\u65f6\u95f4\u51fd\u6570\uff0c\u4f60\u9700\u8981\u5305\u542btime.h\u5934\u6587\u4ef6\uff0c\u5e76\u94fe\u63a5\u5bf9\u5e94\u7684\u5e93\uff08\u901a\u5e38\u662flibrt.so\uff09\u3002 \u8bf7\u6ce8\u610f\uff0c\u4e0d\u540c\u7684\u64cd\u4f5c\u7cfb\u7edf\u53ef\u80fd\u4f1a\u6709\u6240\u5dee\u5f02\uff0c\u6240\u4ee5\u5728\u4f7f\u7528\u65f6\u5efa\u8bae\u67e5\u9605\u76f8\u5173\u7684\u6587\u6863\u6216\u624b\u518c\u4ee5\u83b7\u53d6\u51c6\u786e\u7684\u51fd\u6570\u5b9a\u4e49\u548c\u4f7f\u7528\u65b9\u6cd5\u3002 \u4ee5\u4e0a\u5c31\u662f\u4e0b\u7684c\u8bed\u8a00\u6709\u65f6\u95f4\u51fd\u6570\u5417\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8FDCServers\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-61761","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/61761","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=61761"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/61761\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=61761"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=61761"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=61761"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}