clock ----获取时间和操作时间
语法:
clock option ?arg arg ...?
该命令可以用来获取或者操作表示时间的字符串或者数值。option选项决定该命令执行的操作。合法的option如下:
clock clicks ?-milliseconds?
高解析度计数器,精度为ms,也可以是系统自行确定
clock scan string ?-base clock? ?-gmt boolean?
解析string字符串并返回秒值。clock值决定于string
clock seconds
以秒数返回当前时间
clock format value ?-format str?
根据str格式化时钟值
clock format的有效描述符:
%%
插入 %.
%a
星期名字的缩写 (Mon, Tue, etc.).
%A
星期名字的全称 (Monday, Tuesday, etc.).
%b
月份名字的缩写 (Jan, Feb, etc.).
%B
月份名字的全称
%c
特定的时间和日期。 The format for date and time in the default "C" locale on Unix/Mac is "%a %b %d %H:%M:%S %Y". On Windows, this value is the locale specific long date and time, as specified in the Regional Options control panel settings.
%C
四位年份的头两位 (19 or 20).
%d
月份内的天数 (01 - 31).
%D
以 %m/%d/%y 显式的日期
%e
月份的日期,没有头0
%g
The ISO8601 year number corresponding to the ISO8601 week (%V), expressed as a two-digit year-of-the-century, with leading zero if necessary.
%G
The ISO8601 year number corresponding to the ISO8601 week (%V), expressed as a four-digit number.
%h
缩写的月份名称
%H
24小时的时间表示 (00 - 23).
%I
12小时的时间表示 (01 - 12).
%j
一年中的某一天数 (001 - 366).
%k
Hour in 24-hour format, without leading zeros (0 - 23).
%l
Hour in 12-hour format, without leading zeros (1 - 12).
%m
月份数 (01 - 12).
%M
分钟数 (00 - 59).
%n
插入新行
%p
AM/PM 提示
%r
Time in a locale-specific "meridian" format. The "meridian" format in the default "C" locale is "%I:%M:%S %p".
%R
以 %H:%M 显式的时间
%s
Count of seconds since the epoch, expressed as a decimal integer.
%S
秒数 (00 - 59).
%t
插入制表符
%T
以%H:%M:%S计时
%u
星期代表的数字 (Monday = 1, Sunday = 7).
%U
一年的星期数 (00 - 52), Sunday is the first day of the week.
%V
Week of year according to ISO-8601 rules. Week 1 of a given year is the week containing 4 January.
%w
星期代表的数字 (Sunday = 0, Saturday = 6).
%W
一年的星期数 (00 - 52), Monday is the first day of the week.
%x
Locale specific date format. The format for a date in the default "C" locale for Unix/Mac is "%m/%d/%y". On Windows, this value is the locale specific short date format, as specified in the Regional Options control panel settings.
%X
Locale specific 24-hour time format. The format for a 24-hour time in the default "C" locale for Unix/Mac is "%H:%M:%S". On Windows, this value is the locale specific time format, as specified in the Regional Options control panel settings.
%y
Year without century (00 - 99).
%Y
Year with century (e.g. 1990)
%Z
Time zone name.
举例:
对于clock format value ?-format str?
默认方式以"%a %b %d %H:%M:%S %Z %Y"输出时间
clock format [clock seconds]和clock format [clock seconds] -format "%a %b %d %H:%M:%S %Z %Y"输出效果一样
clock format [clock second] -format "%a %b %d %H:%M:%S %Z %Y"
=> Fri Nov 22 4:09:14 PM PST 2002
clock format [clock seconds]
=> Fri Nov 22 4:09:14 PM PST 2002
对于clock scan string ?-base clock? ?-gmt boolean?
clock scan "10:30:44 PM" -base [clock seconds]
=> 2931690644
clock format [clock scan "10:30:44 PM 1 week"]
=> Fri Nov 29 10:30:44 PM PST 2002
clock format [clock scan "10:30:44 PM -1 week"]
Fri Nov 15 10:30:44 PM PST 2002
阅读(2656) | 评论(0) | 转发(1) |