Linux命令之日期时间命令date使用实例
date用法1:
格式:date [option]... [+format]
format controls the output. interpreted sequences are:
%% a literal %
%a locale's abbreviated weekday name (e.g., sun)
%a locale's full weekday name (e.g., sunday)
%b locale's abbreviated month name (e.g., jan)
%b locale's full month name (e.g., january)
%c locale's date and time (e.g., thu mar 3 23:05:25 2005)
%c century; like %y, except omit last two digits (e.g., 20)
%d day of month (e.g., 01)
%d date; same as %m/%d/%y
%e day of month, space padded; same as %_d
%f full date; same as %y-%m-%d
%g last two digits of year of iso week number (see %g)
%g year of iso week number (see %v); normally useful only with %v
%h same as %b
%h hour (00..23)
%i hour (01..12)
%j day of year (001..366)
%k hour, space padded ( 0..23); same as %_h
%l hour, space padded ( 1..12); same as %_i
%m month (01..12)
%m minute (00..59)
%n a newline
%n nanoseconds (000000000..999999999)
%p locale's equivalent of either am or pm; blank if not known
%p like %p, but lower case
%r locale's 12-hour clock time (e.g., 11:11:04 pm)
%r 24-hour hour and minute; same as %h:%m
%s seconds since 1970-01-01 00:00:00 utc
%s second (00..60)
%t a tab
%t time; same as %h:%m:%s
%u day of week (1..7); 1 is monday
%u week number of year, with sunday as first day of week (00..53)
%v iso week number, with monday as first day of week (01..53)
%w day of week (0..6); 0 is sunday
%w week number of year, with monday as first day of week (00..53)
%x locale's date representation (e.g., 12/31/99)
%x locale's time representation (e.g., 23:13:48)
%y last two digits of year (00..99)
%y year
%z +hhmm numeric time zone (e.g., -0400)
%:z +hh:mm numeric time zone (e.g., -04:00)
%::z +hh:mm:ss numeric time zone (e.g., -04:00:00)
%:::z numeric time zone with : to necessary precision (e.g., -04, +05:30)
%z alphabetic time zone abbreviation (e.g., edt)
by default, date pads numeric fields with zeroes. the following optional flags may follow `%':
- (hyphen) do not pad the field
_ (underscore) pad with spaces
0 (zero) pad with zeros
^ use upper case if possible
# use opposite case if possible
例如:
1.年月日
$ date +%y%m%d
20150107
2.年月日,年只保留后两位
~$ date +%y%m%d
150107
3.小时分钟秒
~$ date +%h%m%s
233045
4.年月日时分秒
~$ date +%y%m%d%h%m%s
20150107233145
下一篇: Spring MVC
推荐阅读
-
unix时间戳转换成时间命令(linux时间戳转换日期格式)
-
unix时间戳转换成时间命令(linux时间戳转换日期格式)
-
我使用过的Linux命令之ifconfig - 网络配置命令 博客分类: Linux命令 LinuxVmwareifconfigeth0network
-
Linux命令date 日期时间和Unix时间戳互转
-
我使用过的Linux命令之wc - 统计文件行数、单词数或字节数 博客分类: Linux命令 Linuxwc
-
php设计模式之命令模式使用示例_php实例
-
linux中cd命令使用详解_php实例
-
Linux系统中的ps进程查看命令使用实例集锦
-
Linux date 显示设置时间命令学习
-
Linux 命令之 date 命令-显示或设置系统时间与日期