0% found this document useful (0 votes)
12 views1 page

strftime Format String Reference Guide

Uploaded by

kathorekunal8
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views1 page

strftime Format String Reference Guide

Uploaded by

kathorekunal8
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

strftime Reference © 2008 Jo Hund, [Link]

ca, r1

Second Day
%S [00-60] seconds %A [Monday, Tuesday, ...] full weekday name
%s number of seconds since the Epoch, UTC %a [Mon, Tue, ...] abbreviated weekday name
%d [01-31] day of the month number
%e [ 1-31] day of month number; single digits
Minute are preceded by a blank

%M [00-59] minutes %j [001-366] day of the year number


%u [1-7] weekday number (Monday as the first
day of the week)

Hour %w [0-6] weekday number (Sunday as the first


day of the week)
%H [00-23] hours (24-hour clock)
%I [01-12] hours (12-hour clock); this is the
upper case i
%k [ 0-23] hours (24-hour clock); single digits
Week
are preceded by a blank %U [00-53] week number of the year (Sunday as
%l [ 1-12] hours (12-hour clock); single digits the first day of the week)
are preceded by a blank; is lower case L %V [01-53] week number of the year (Monday
as the first day of the week). If the week
containing January 1 has four or more days
in the new year, then it is week 1; otherwise
Other it is the last week of the previous year, and
%n newline the next week is week 1
%p [AM, PM] as appropriate %M [00-53] week number of the year (Monday
as the first day of the week)
%t tab
%Z time zone name
%z time zone offset from UTC; a leading plus
sign stands for east of UTC, a minus sign Month
for west of UTC, hours and minutes follow
with two digits each and no delimiter %B [January, February, ...] full month name
between them %b [Jan, Feb, ...] abbreviated month name
%% % (the percent sign) %h abbreviated month name (like %b)
%m [01-12] month number

Macros
%c national representation of time and date Year
%+ national representation of date and time
%C [19, 20, ...] (year / 100) number; single digits
%D equivalent to '%m/%d/%y' are preceded by a zero
%F equivalent to '%Y-%m-%d' %G [1999, 2000, ...] year number with century.
%R equivalent to '%H:%M' This year is the one that contains the
greater part of the week (Monday as the first
%r equivalent to '%I:%M:%S %p' day of the week)
%T equivalent to '%H:%M:%S' %g [00-99] same year as in '%G', but as a
%v equivalent to '%e-%b-%Y' decimal number without century
%X national representation of time %Y [1999, 2000, ...] year with century number
%x national representation of date %y [00-99] year without century number

This reference is optimized for building format strings. For decoding a format string, just look at the man page which is sorted alphabetically.

Common questions

Powered by AI

In strftime, '%w' represents the weekday as a number with Sunday as the first day (0-6), while '%u' represents it with Monday as the first day (1-7). This distinction allows for flexibility when adapting to different cultural or regional norms in defining the structure of a week .

strftime uses '%C' for the century (as a two-digit zero-padded number), '%Y' for the full year with century, and '%y' for the year without century. These distinctions are necessary for determining long-term time data such as historical events versus future predictions .

In strftime, '%z' represents the time zone offset from UTC in +/-HHMM format, while '%Z' denotes the time zone name. These formats are essential for handling global time representation and ensuring that time outputs are accurately adjusted for different time zones .

The '%j' specifier in strftime returns the day of the year as a zero-padded decimal number, ranging from 001 to 366. This is useful for calculating elapsed time within a year without the need to consider month variations in days .

strftime uses '%B' for full month names (e.g., January, February) and either '%b' or '%h' for abbreviated month names (e.g., Jan, Feb). These distinctions allow for formatting flexibility depending on the space available or the formality required in the display .

strftime ensures compatibility with various cultural date formats through specifiers like '%x', '%X', '%c', and '%D' that provide national representations of date and time. For example, '%x' is for dates, '%X' for times, '%c' for date and time together, and '%D' uses 'm/d/y' format .

strftime provides macros like '%r', '%R', '%T', and '%F' for specific time and date representations. '%r' is for 12-hour time with AM/PM, '%R' for 24-hour time without seconds, '%T' for a 24-hour time including seconds, and '%F' for the date in the format 'year-month-day'. These macros simplify formatting and enhance readability by reducing the need for multiple specifiers .

In strftime, the 12-hour clock format is represented using '%I' for zero-padded numbers from 01 to 12, and '%l' for space-padded numbers from 1 to 12, where single digits are preceded by a blank .

In strftime, '%s' outputs the number of seconds since the Epoch (1970-01-01 00:00:00 UTC), facilitating precise date-time calculations and timestamp generation. This is vital for time-based operations and synchronizing time across different systems .

The '%V' format specifier in strftime represents the ISO 8601 week number of the year, where weeks start on Monday. The week containing January 1 must have four or more days in the new year to be week 1; otherwise, it's the last week of the previous year. The next week is considered week 1 of the current year .

You might also like