linuxϵͳʱ¼äÔõô»ñÈ¡
ÔÚ linux ϵͳÖлñȡϵͳʱ¼äµÄÒªÁìÓжàÖÖ£ºÊ¹Óà date ÏÂÁîÖ±½ÓÊä³öÄ¿½ñʱ¼ä¡£Ê¹Óà date +%s ÏÂÁî»ñÈ¡ unix ʱ¼ä´Á¡£Ê¹Óà date +% Ñ¡ÏîÖ¸¶¨ÌØÃüÃûÌõÄʱ¼ä¡£Ê¹Óà date ÏÂÁîµÄ -u ºÍ -z Ñ¡Ïî»ñÈ¡ÆäËûʱÇøµÄʱ¼ä¡£
ÔõÑù»ñÈ¡ Linux ϵͳʱ¼ä
ÔÚ Linux ϵͳÖУ¬»ñȡϵͳʱ¼äµÄÒªÁìÓжàÖÖ£¬ÕâÈ¡¾öÓÚËùÐèµÄ¾«¶ÈºÍÃûÌá£
Ö±½ÓÊä³öÄ¿½ñʱ¼ä
ÒªÖ±½ÓÊä³öÄ¿½ñʱ¼ä£¬¿ÉÒÔʹÓà date ÏÂÁ
date
µÇ¼ºó¸´ÖÆ
Õ⽫Êä³öÀàËÆÒÔÏÂÃûÌõÄÄ¿½ñʱ¼ä£º
Tue Apr 12 14:31:23 CST 2023
µÇ¼ºó¸´ÖÆ
»ñÈ¡ UNIX ʱ¼ä´Á
UNIX ʱ¼ä´ÁÊÇ×Ô 1970 Äê 1 Ô 1 ÈÕÎçÒ¹ (UTC) ÒÔÀ´¾ÓɵÄÃëÊý¡£Òª»ñÈ¡ UNIX ʱ¼ä´Á£¬¿ÉÒÔʹÓà date +%s ÏÂÁ
date +%s
µÇ¼ºó¸´ÖÆ
Õ⽫Êä³öÒ»¸öÊý×Ö£¬ÌåÏÖÄ¿½ñʱ¼äÒÔ UNIX ʱ¼ä´ÁÌåÏÖ¡£
»ñÈ¡ÌØÃüÃûÌõÄʱ¼ä
Òª»ñÈ¡ÌØÃüÃûÌõÄʱ¼ä£¬¿ÉÒÔʹÓà date ÏÂÁîµÄ +% Ñ¡Ïî¡£ÀýÈ磬Ҫ»ñÈ¡ ISO 8601 ÃûÌõÄʱ¼ä£¬¿ÉÒÔʹÓãº
date +%Y-%m-%dT%H:%M:%SZ
µÇ¼ºó¸´ÖÆ
Õ⽫Êä³öÀàËÆÒÔÏÂÃûÌõÄʱ¼ä£º
2023-04-12T14:31:23Z
µÇ¼ºó¸´ÖÆ
»ñÈ¡ÆäËûʱÇøµÄʱ¼ä
Òª»ñÈ¡ÆäËûʱÇøµÄʱ¼ä£¬¿ÉÒÔʹÓà date ÏÂÁîµÄ -u ºÍ -z Ñ¡Ïî¡£ÀýÈ磬Ҫ»ñÈ¡ÃÀ¹ú¶«²¿Ê±¼äµÄʱ¼ä£¬¿ÉÒÔʹÓãº
date -u -z America/New_York
µÇ¼ºó¸´ÖÆ
Õ⽫Êä³öÀàËÆÒÔÏÂÃûÌõÄʱ¼ä£º
Tue Apr 12 10:31:23 EDT 2023
µÇ¼ºó¸´ÖÆ
ÒÔÉϾÍÊÇlinuxϵͳʱ¼äÔõô»ñÈ¡µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡