Raspberry Pi【6】桌面时间的格式设置

2021-09-24
#Unix

1. 设置方法

Raspberry Pi桌面的右上角,右键选择Digital Clock Settings,在Clock Format输入:%A %d %b, %Y - %T,显示的内容为:Friday 24 Sep, 2021 - 15:00:00

2. 说明

在终端输入:

man strftime

Digital clock format strings for Week & Day of Week:

  • %a – The abbreviated name of the day of the week.
  • %A – The full name of the day of the week.
  • %u – The day of the week as a decimal, (1 to 7), Monday being 1.
  • %w – The day of the week as a decimal (0 to 6), Sunday being 0.
  • %U – The week number of current year as a decimal number (00 to 53).
  • %V – The ISO 8601-week number.
  • %W – The week number of the current year as a decimal number (00 to 53).
  • %j – The day of the year as a decimal number (001 to 366).

Digital clock format strings for Day & Month:

  • %b – The abbreviated month name.
  • %B – The full month name.
  • %d – The day of the month as a decimal number (01 to 31).
  • %h – Equivalent to %b.
  • %m – The month as a decimal number (01 to 12).
  • %M – The minute as a decimal number (00 to 59).

Digital clock format strings for Date and Time:

  • %c – The preferred date and time representation for the current locale.
  • %D – Equivalent to %m/%d/%y. %e – Like %d, the day of the month as a decimal number with leading space.
  • %F – Equivalent to %Y-%m-%d (the ISO 8601 date format).
  • %x – The preferred date representation without the time.
  • %+ – The date and time in date (1) format.

Digital clock format strings for Year:

  • %C – The century number (year/100) as a 2-digit integer.
  • %G – The ISO 8601 week-based year.
  • %g – Like %G, but without century, that is, with a 2-digit year (00–99).
  • %y – The year as a decimal number without a century (00 to 99).
  • %Y – The year as a decimal number including the century.

Digital clock format strings for Time & Time zone:

  • %p – Either “AM” or “PM” according to the given time value.
  • %P – Like %p but in lowercase: “am” or “pm”.
  • %r – The time in a.m. or p.m. notation.
  • %R – The time in 24-hour notation (%H:%M).
  • %T – The time in 24-hour notation (%H:%M:%S)
  • %H – The hour as a decimal number using a 24-hour clock (00 to 23).
  • %I – The hour as a decimal number using a 12-hour clock (01 to 12).
  • %k – The hour (24-hour clock) as a decimal number (0 to 23).
  • %l – The hour (12-hour clock) as a decimal number (1 to 12).
  • %s – The number of seconds since the Epoch, 1970-01-01 00:00:00 +0000.
  • %S – The second as a decimal number (00 to 60).
  • %X – The preferred time representation without the date.
  • %z – The +hhmm or -hhmm numeric time zone (hour & minute offset from UTC).
  • %Z – The time zone name or abbreviation.

Special Characters and Modifiers:

  • %n – A newline character.
  • %t – A tab character.
  • %% – A literal ‘%’ character.

3. 参考