Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

C/C++ÖеÄÈÕÆÚºÍʱ¼ä

תÔØÓÚÕâÀhttp://www.programfan.com/article/showarticle.asp?id=2798
²»Ì«¶®ÈçºÎ¶ÔÔËÓÃc++µÄʱ¼äº¯ÊýµÄÅóÓѶ࿴¿´°É¡£
*************************ÆÓËصķָîÏß**********************************
׫ÎÄ/ÖÜÏè
ͻ񻣼
±¾ÎÄ´Ó½éÉÜ»ù´¡¸ÅÄîÈëÊÖ£¬Ì½ÌÖÁËÔÚC/C++ÖжÔÈÕÆÚºÍʱ¼ä²Ù×÷ËùÓõ½µÄÊý¾Ý½á¹¹ºÍº¯Êý£¬²¢¶Ô¼Æʱ¡¢Ê±¼äµÄ»ñÈ¡¡¢Ê±¼äµÄ¼ÆËãºÍÏÔʾ¸ñʽµÈ·½Ãæ½øÐÐÁ˲ûÊö¡£±¾ÎÄ»¹Í¨¹ý´óÁ¿µÄʵÀýÏòÄãչʾÁËtime.hÍ·ÎļþÖÐÉùÃ÷µÄ¸÷ÖÖº¯ÊýºÍÊý¾Ý½á¹¹µÄÏêϸʹÓ÷½·¨¡£
¹Ø¼ü×Ö£ºUTC£¨ÊÀ½ç±ê׼ʱ¼ä£©£¬Calendar Time£¨ÈÕÀúʱ¼ä£©£¬epoch£¨Ê±¼äµã£©£¬clock tick£¨Ê±ÖÓ¼Æʱµ¥Ôª£©
1£®¸ÅÄî
ÔÚC/C++ÖУ¬¶Ô×Ö·û´®µÄ²Ù×÷ÓкܶàÖµµÃ×¢ÒâµÄÎÊÌ⣬ͬÑù£¬C/C++¶Ôʱ¼äµÄ²Ù×÷Ò²ÓÐÐí¶àÖµµÃ´ó¼Ò×¢ÒâµÄµØ·½¡£×î½ü£¬ÔÚ¼¼ÊõȺÖÐÓкܶàÍøÓÑÒ²¶à´ÎÎʵ½
¹ýC++ÓïÑÔÖжÔʱ¼äµÄ²Ù×÷¡¢»ñÈ¡ºÍÏÔʾµÈµÈµÄÎÊÌâ¡£ÏÂÃ棬ÔÚÕâƪÎÄÕÂÖУ¬±ÊÕß½«Ö÷Òª½éÉÜÔÚC/C++ÖÐʱ¼äºÍÈÕÆÚµÄʹÓ÷½·¨.
ͨ¹ýѧϰÐí¶àC/C++¿â£¬Äã¿ÉÒÔÓкܶà²Ù×÷¡¢Ê¹ÓÃʱ¼äµÄ·½·¨¡£µ«ÔÚÕâ֮ǰÄãÐèÒªÁ˽âһЩ“ʱ¼ä”ºÍ“ÈÕÆÚ”µÄ¸ÅÄÖ÷ÒªÓÐÒÔϼ¸¸ö£º
Coordinated Universal
Time£¨UTC£©£ºÐ­µ÷ÊÀ½çʱ£¬ÓÖ³ÆΪÊÀ½ç±ê׼ʱ¼ä£¬Ò²¾ÍÊÇ´ó¼ÒËùÊìÖªµÄ¸ñÁÖÍþÖαê׼ʱ¼ä£¨Greenwich Mean
Time£¬GMT£©¡£±ÈÈ磬ÖйúÄڵصÄʱ¼äÓëUTCµÄʱ²îΪ+8£¬Ò²¾ÍÊÇUTC+8¡£ÃÀ¹úÊÇUTC-5¡£
Calendar
Time£ºÈÕÀúʱ¼ä£¬ÊÇÓÓ´ÓÒ»¸ö±ê׼ʱ¼äµãµ½´ËʱµÄʱ¼ä¾­¹ýµÄÃëÊý”À´±íʾµÄʱ¼ä¡£Õâ¸ö±ê׼ʱ¼äµã¶Ô²»Í¬µÄ±àÒëÆ÷À´Ëµ»áÓÐËù²»Í¬£¬µ«¶ÔÒ»¸ö±àÒëϵͳÀ´
˵£¬Õâ¸ö±ê׼ʱ¼äµãÊDz»±äµÄ£¬¸Ã±àÒëϵͳÖеÄʱ¼ä¶ÔÓ¦µÄÈÕÀúʱ¼ä¶¼Í¨¹ý¸Ã±ê׼ʱ¼äµãÀ´ºâÁ¿£¬ËùÒÔ¿ÉÒÔ˵ÈÕÀúʱ¼äÊÇ“Ïà¶Ôʱ¼ä”£¬µ«ÊÇÎÞÂÛÄãÔÚÄÄÒ»¸öʱÇø£¬
ÔÚͬһʱ¿Ì¶Ôͬһ¸ö±ê׼ʱ¼äµãÀ´Ëµ£¬ÈÕÀúʱ¼ä¶¼ÊÇÒ»ÑùµÄ¡£
epoch£ºÊ±¼äµã¡£Ê±¼äµãÔÚ±ê×¼C/C++ÖÐÊÇÒ»¸öÕûÊý£¬ËüÓôËʱµÄʱ¼äºÍ±ê׼ʱ¼äµãÏà²îµÄÃëÊý£¨¼´ÈÕÀúʱ¼ä£©À´±íʾ¡£
clock tick£ºÊ±ÖÓ¼Æʱµ¥Ôª£¨¶ø²»°ÑËü½Ð×öʱÖӵδð´ÎÊý£©£¬Ò»¸öʱÖÓ¼Æʱµ¥ÔªµÄʱ¼ä³¤¶ÌÊÇÓÉCPU¿ØÖƵġ£Ò»¸öclock tick²»ÊÇCPUµÄÒ»¸öʱÖÓÖÜÆÚ£¬¶øÊÇC/C++µÄÒ»¸ö»ù±¾¼Æʱµ¥Î»¡£
ÎÒÃÇ¿ÉÒÔʹÓÃANSI±ê×¼¿âÖеÄtime.hÍ·Îļþ¡£Õâ¸öÍ·ÎļþÖж¨ÒåµÄʱ¼äºÍÈÕÆÚËùʹÓõķ½·¨£¬ÎÞÂÛÊÇÔڽṹ¶¨Ò壬»¹ÊÇÃüÃû£¬¶¼¾ßÓÐÃ÷ÏÔµÄCÓïÑÔ·ç¸ñ¡£ÏÂÃ棬ÎÒ½«ËµÃ÷ÔÚC/C++ÖÐÔõÑùʹÓÃÈÕÆÚµÄʱ¼ä¹¦ÄÜ¡£
2£® ¼Æʱ
C/C++ÖеļÆʱº¯ÊýÊÇclock()£¬¶øÓë


Ïà¹ØÎĵµ£º

CÓïÑÔÊý×é


ÔÚ³ÌÐòÉè¼ÆÖУ¬ÎªÁË´¦Àí·½±ã£¬°Ñ¾ßÓÐÏàͬÀàÐ͵ÄÈô¸É±äÁ¿°´ÓÐÐòµÄÐÎʽ×éÖ¯ÆðÀ´¡£ÕâЩ°´ÐòÅÅÁеÄͬÀàÊý¾ÝÔªËصļ¯ºÏ³ÆΪÊý×é¡£ÔÚ£ÃÓïÑÔÖУ¬Êý×éÊôÓÚ¹¹ÔìÊý¾ÝÀàÐÍ¡£Ò»¸öÊý×é¿ÉÒÔ·Ö½âΪ¶à¸öÊý×éÔªËØ£¬ÕâЩÊý×éÔªËØ¿ÉÒÔÊÇ»ù±¾Êý¾ÝÀàÐÍ»òÊǹ¹ÔìÀàÐÍ¡£Òò´Ë°´Êý×éÔªËصÄÀàÐͲ»Í¬£¬Êý×éÓÖ¿É·ÖΪÊýÖµÊý×é¡¢×Ö·ûÊý×é¡¢Ö¸ÕëÊý×é¡¢½á¹ ......

CÓïÑÔÖ¸Õ루һ£©


Ö¸ÕëÊÇ£ÃÓïÑÔÖй㷺ʹÓõÄÒ»ÖÖÊý¾ÝÀàÐÍ¡£ÔËÓÃÖ¸Õë±à³ÌÊÇ£ÃÓïÑÔ×îÖ÷ÒªµÄ·ç¸ñÖ®Ò»¡£ÀûÓÃÖ¸Õë±äÁ¿¿ÉÒÔ±íʾ¸÷ÖÖÊý¾Ý½á¹¹£»Äܷܺ½±ãµØʹÓÃÊý×éºÍ×Ö·û´®£»²¢ÄÜÏó»ã±àÓïÑÔÒ»Ñù´¦ÀíÄÚ´æµØÖ·£¬´Ó¶ø±à³ö¾«Á·¶ø¸ßЧµÄ³ÌÐò¡£Ö¸Õ뼫´óµØ·á¸»ÁË£ÃÓïÑԵŦÄÜ¡£Ñ§Ï°Ö¸ÕëÊÇѧϰ£ÃÓïÑÔÖÐ×îÖØÒªµÄÒ»»·£¬ÄÜ·ñÕýÈ·Àí½âºÍʹÓÃÖ¸ÕëÊÇÎÒÃÇÊÇ·ñÕÆÎÕ ......

ΪʲôѡÔñCÓïÑÔ

ΪʲôCÓïÑÔÒÀÈ»Èç´ËÁ÷ÐУ¿ÀúÊ·ÉÏ£¬ÓÉÓÚÖÖÖÖÔ­Òò£¬Òµ½çÑ¡ÔñÁËC£¬ÆäÖÐ×îÖ÷ÒªµÄÔ­Òò¾ÍÔÚÓÚËüµÄЧÂÊ¡£ÓÅÐãµÄC³ÌÐòµÄЧÂʼ¸ºõºÍ»ã
±àÓïÑÔ³ÌÐòÒ»Ñù¸ß£¬µ«C³ÌÐòÃ÷ÏԱȻã±àÓïÑÔ³ÌÐò¸üÒ×ÓÚ¿ª·¢¡£ºÍÐí¶àÆäËûÓïÑÔÏà±È£¬C¸øÓè³ÌÐòÔ±¸ü¶àµÄ¿ØÖÆȨ£¬Èç¿ØÖÆÊý¾ÝµÄ´æ´¢Î»Öúͳõʼ»¯¹ý³ÌµÈ¡£Cȱ·¦“°²È«Íø”ÌØÐÔ£¬ÕâËäÓÐÖúÓÚÌá¸ß ......

CÓïÑÔº¯Êýµ÷ÓÃÔ¼¶¨


תÔØ×Ô£º
Ü°ÈÙ¼ÒÔ°blog
ÔÚCÓïÑÔÖУ¬¼ÙÉèÎÒÃÇÓÐÕâÑùµÄÒ»¸öº¯Êý£º
int function(int a,int b)
µ÷
ÓÃʱֻҪÓÃresult =
function(1,2)ÕâÑùµÄ·½Ê½¾Í¿ÉÒÔʹÓÃÕâ¸öº¯Êý¡£µ«ÊÇ£¬µ±¸ß¼¶ÓïÑÔ±»±àÒë³É¼ÆËã»ú¿ÉÒÔʶ±ðµÄ»úÆ÷Âëʱ£¬ÓÐÒ»¸öÎÊÌâ¾Í͹ÏÖ³öÀ´£ºÔÚCPUÖУ¬¼ÆËã
»úûÓа취֪µÀÒ»¸öº¯Êýµ÷ÓÃÐèÒª¶àÉÙ¸ö¡¢Ê²Ã´ÑùµÄ²ÎÊý£¬Ò² ......

C/C++ ÈÕÆÚ Ê±¼ä time_tÓëstruct tmת»»

±¾ÎÄ´Ó½éÉÜ»ù´¡¸ÅÄîÈëÊÖ£¬Ì½ÌÖÁËÔÚC/C++ÖжÔÈÕÆÚºÍʱ¼ä²Ù×÷ËùÓõ½µÄÊý¾Ý½á¹¹ºÍº¯Êý£¬²¢¶Ô¼Æʱ¡¢Ê±¼äµÄ»ñÈ¡¡¢Ê±¼äµÄ¼ÆËãºÍÏÔʾ¸ñʽµÈ·½Ãæ½øÐÐÁ˲ûÊö¡£±¾ÎÄ»¹Í¨¹ý´óÁ¿µÄʵÀýÏòÄãչʾÁËtime.hÍ·ÎļþÖÐÉùÃ÷µÄ¸÷ÖÖº¯ÊýºÍÊý¾Ý½á¹¹µÄÏêϸʹÓ÷½·¨¡£
¹Ø¼ü×Ö£ºUTC£¨ÊÀ½ç±ê׼ʱ¼ä£©£¬Calendar Time£¨ÈÕÀúʱ¼ä£©£¬epoch£¨Ê±¼äµã£©£¬cl ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ