리눅스 date

1 개요[ | ]

리눅스 date
/bin/date
  • 시스템 날짜, 시간을 출력 또는 변경하는 리눅스 명령어
  • 만약 리눅스 환경변수 $TZ가 설정되어 있으면 시스템 시간대 설정보다 우선적 적용된다.
따라서 특별한 경우가 아니라면 리눅스 환경변수 $TZ는 설정하지 않는 것이 좋을 것 같다.

2 실행예시 1[ | ]

[root@zetawiki ~]# date
Tue Mar 11 22:15:33 KST 2014
[root@zetawiki ~]# date '+%F %T'
2014-03-11 22:15:33
[root@zetawiki ~]# date +%F
2014-03-11
[root@zetawiki ~]# date --date 'today'
Thu May 14 22:28:34 KST 2015
[root@zetawiki ~]# date --date '1 week ago'
Thu May  7 22:28:39 KST 2015
[root@zetawiki ~]# date --date '3 years ago 1 week ago'
Mon May  7 22:29:02 KST 2012

3 실행예시 2: LANG[ | ]

[root@zetawiki ~]# LANG=ko_KR.UTF-8 date
2014. 03. 11. (화) 22:15:33 KST
[root@zetawiki ~]# LANG=fr_FR.UTF-8 date
mar. mars 11 22:15:33 KST 2014

4 포메팅 옵션[ | ]

Format option Part of Date Desciption Example Output
date +%a Weekday Name of weekday in short (like Sun, Mon, Tue, Wed, Thu, Fri, Sat) Mon
date +%A Weekday Name of weekday in full (like Sunday, Monday, Tuesday) Monday
date +%b Month Name of Month in short (like Jan, Feb, Mar ) Jan
date +%B Month Month name in full short (like January, February) January
date +%d Day Day of month (e.g., 01) 04
date +%D MM/DD/YY Current Date; shown in MM/DD/YY 02/18/18
date +%F YYYY-MM-DD Date; shown in YYYY-MM-DD 2018-01-19
date +%H Hour Hour in 24-hour clock format 18
date +%I Hour Hour in 12-hour clock format 10
date +%j Day Day of year (001..366) 152
date +%m Month Number of month (01..12) (01 is January) 05
date +%M Minutes Minutes (00..59) 52
date +%S Seconds Seconds (00..59) 18
date +%N Nanoseconds Nanoseconds (000000000..999999999) 300231695
date +%T HH:MM:SS Time as HH:MM:SS (Hours in 24 Format) 18:55:42
date +%u Day of Week Day of week (1..7); 1 is Monday 7
date +%U Week Displays week number of year, with Sunday as first day of week (00..53) 23
date +%Y Year Displays full year i.e. YYYY 2018
date +%Z Timezone Time zone abbreviation (Ex: IST, GMT) IST

5 같이 보기[ | ]

6 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}