Linux Tips

Format date and time for Linux shell script or variable

 

%a     locales abbreviated weekday title (e.g., Solar)

 

%A     locales full weekday title (e.g., Sunday)

 

%b     locales abbreviated month title (e.g., Jan)

 

%B     locales full month title (e.g., January)

 

%c     locales date and time (e.g., Thu Mar  three 23:05:25 2005)

 

%C     century; like %Y, besides omit final two digits (e.g., 20)

 

%d     day of month (e.g, 01)

 

%D     date; similar as %m/%d/%y

 

%e     day of month, house padded; similar as %_d

 

%F     full date; similar as %Y%m%d

 

%g     final two digits of 12 months of ISO week quantity (see %G)

 

%G     12 months of ISO week quantity (see %V); usually helpful solely with %V

 

%h     similar as %b

 

%H     hour (00..23)

 

%I     hour (01..12)

 

%j     day of 12 months (001..366)

 

%ok     hour ( zero..23)

 

%l     hour ( 1..12)

 

%m     month (01..12)

 

%M     minute (00..59)

 

%N     nanoseconds (000000000..999999999)

 

%p     locales equal of both AM or PM; clean if not identified

 

%P     like %p, however decrease case

 

%r     locales 12hour clock time (e.g., 11:11:04 PM)

 

%R     24hour hour and minute; similar as %H:%M

 

%s     seconds since 19700101 00:00:00 UTC

 

%S     second (00..60)

 

%T     time; similar as %H:%M:%S

 

%u     day of week (1..7); 1 is Monday

 

%U     week quantity of 12 months, with Sunday as first day of week (00..53)

 

%V     ISO week quantity, with Monday as first day of week (01..53)

 

%w     day of week (zero..6); zero is Sunday

 

%W     week quantity of 12 months, with Monday as first day of week (00..53)

 

%x     locales date illustration (e.g., 12/31/99)

 

%X     locales time illustration (e.g., 23:13:48)

 

%y     final two digits of 12 months (00..99)

 

%Y     12 months

 

%z     +hhmm numeric timezone (e.g., 0400)

 

%:z    +hh:mm numeric timezone (e.g., 04:00)

 

%::z   +hh:mm:ss numeric time zone (e.g., 04:00:00)

 

%Z     alphabetic time zone abbreviation (e.g., EDT)

 

Source link

Related Articles

Back to top button