R语言的时间格式

格式 說明

%a Abbreviated weekday name

%A Full weekday name

%b Abbreviated month name

%B Full month name

%c Date and time, locale-specific.

%d Day of the month as decimal number (01-31).

%H Hours as decimal number (00-23).

%I Hours as decimal number (01-12).

%j Day of year as decimal number (001-366).

%m Month as decimal number (01-12).

%M Minute as decimal number (00-59).

%p AM/PM indicator in the locale.

Used in conjuction with ’%I’ and *not* with ’%H’.

%S Second as decimal number (00-61), allowing for up to two leap-seconds

%U Week of the year as decimal number (00-53)

using the first Sunday as day 1 of week 1.

%w Weekday as decimal number (0-6, Sunday is 0).

%W Week of the year as decimal number (00-53)

using the first Monday as day 1 of week 1.

%x Date, locale-specific.

%X Time, locale-specific.

%y Year without century (00-99).

If you use this on input, which century you get is system-specific. So don’t!

Often values up to 69 (or 68) are prefixed by 20 and 70-99 by 19.

%Y Year with century.

%z (output only.) Offset from Greenwich, so ’-0800’ is 8 hours west of Greenwich.

%Z (output only.) Time zone as a character string (empty if not available).

%F Equivalent to %Y-%m-%d (the ISO 8601 date format).

%g The last two digits of the week-based year (see ’%V’).

%G The week-based year (see ’%V’) as a decimal number.

%u Weekday as a decimal number (1-7, Monday is 1).

%V Week of the year as decimal number (00-53).

If the week (starting on Monday) containing 1 January

has four or more days in the new year, then it is considered week 1.

Otherwise, it is the last week of the previous year,

and the next week is week 1.

%D Locale-specific date format such as ’%m/%d/%y’.

%k The 24-hour clock time with single digits preceded by a blank.

%l The 12-hour clock time with single digits preceded by a blank.

%n Newline on output, arbitrary whitespace on input.

%r The 12-hour clock time (using the locale’s AM or PM).

%R Equivalent to ’%H:%M’.

%t Newline on output, arbitrary whitespace on input.

%T Equivalent to ’%H:%M:%S’.

    原文作者:Datacruiser
    原文地址: https://www.jianshu.com/p/59c03182f792
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞