Skip to content

Date

Format

  • %N nanoseconds (000000000..999999999)
  • %s seconds since 1970-01-01 00:00:00 UTC

Current time

will return the number of seconds since the epoch.

$ date +%s

returns the seconds and current nanoseconds.

$ date +%s%N

will give you the number of milliseconds since the epoch - current seconds plus the left three of the nanoseconds.

$ date +%s%N | cut -b1-13

현재시간을 밀리초 단위로 출력하는 방법은 아래와 같다.

$ date +%s%3N

몇 일 전 계산 방법

-d 옵션 사용.

date -d "-1 day" +%Y%m%d

Answer:SteelScrap#cron 을 위한 자동 압축 bash script 에서 사용했다.

See also

Favorite site