YouTip
Home
JavaScript
PHP
Python3
HTML
C#
Python
Java
PyTorch
Linux
C
jQuery
CSS
XML
jQuery UI
Bootstrap
C++
Angular
HTML DOM
Redis
Web Building
Home
>
C
>
C Function Strftime
C Function Strftime
π 2026-06-20 | π C
# C Library Function - strftime() [ C Standard Library -
](#) ## Description The C library function **size_t strftime(char *str, size_t maxsize, const char *format, const struct tm *timeptr)** formats the time represented in the structure **timeptr** according to the formatting rules defined in **format**, and stores the result in the string **str**. ## Declaration Here is the declaration of the strftime() function. size_t strftime(char *str, size_t maxsize, const char *format, const struct tm *timeptr) ## Parameters * **str** -- This is a pointer to the destination array where the resulting C string is copied. * **maxsize** -- This is the maximum number of characters to be copied to str. * **format** -- This is a C string that contains any combination of regular characters and special format specifiers. These format specifiers are replaced by the corresponding values from the tm structure specified by timeptr. The format specifiers are: | Specifier | Replaced by | Example | | --- | --- | --- | | %a | Abbreviated weekday name | Sun | | %A | Full weekday name | Sunday | | %b | Abbreviated month name | Mar | | %B | Full month name | March | | %c | Date and time representation | Sun Aug 19 02:56:02 2012 | | %d | Day of the month (01-31) | 19 | | %H | Hour in 24-hour format (00-23) | 14 | | %I | Hour in 12-hour format (01-12) | 05 | | %j | Day of the year (001-366) | 231 | | %m | Month as a decimal number (01-12) | 08 | | %M | Minute (00-59) | 55 | | %p | AM or PM designation | PM | | %S | Second (00-61) | 02 | | %U | Week number of the year, with the first Sunday as the first day of week 1 (00-53) | 33 | | %w | Weekday as a decimal number, with Sunday as 0 (0-6) | 4 | | %W | Week number of the year, with the first Monday as the first day of week 1 (00-53) | 34 | | %x | Date representation | 08/19/12 | | %X | Time representation | 02:50:06 | | %y | Year without century (00-99) | 01 | | %Y | Year with century | 2012 | | %Z | Timezone name or abbreviation | CDT | | %% | A literal % character | % | * **timeptr** -- This is a pointer to a tm structure that contains a calendar time broken down into its components: struct tm { int tm_sec; /* seconds, 0-59 */ int tm_min; /* minutes, 0-59 */ int tm_hour; /* hours, 0-23 */ int tm_mday; /* day of the month, 1-31 */ int tm_mon; /* month, 0-11 */ int tm_year; /* year since 1900 */ int tm_wday; /* day of the week, 0-6 */ int tm_yday; /* day of the year, 0-365 */ int tm_isdst; /* daylight saving time */}; ## Return Value If the resulting C string is less than size characters (including the terminating null character), the total number of characters copied to str (excluding the null character) is returned. Otherwise, zero is returned. ## Example The following example demonstrates the usage of the strftime() function. ## Example #include#include
int main(){time_t rawtime; struct tm *info; char buffer; time(&rawtime); info = localtime(&rawtime); strftime(buffer, 80, "%Y-%m-%d %H:%M:%S", info); printf("Formatted date & time : |%s|n", buffer); return(0); } Let us compile and run the above program, this will produce the following result: Formatted date & time : |2018-09-19 08:59:07| [ C Standard Library -
](#)
β Md Code
Md Lists β
π Categories
β‘ JavaScript
(1589)
π PHP
(872)
π Python3
(810)
π HTML
(691)
βοΈ C#
(650)
π Python
(594)
β Java
(552)
βοΈ PyTorch
(534)
π§ Linux
(472)
βοΈ C
(432)
π¦ jQuery
(406)
π¨ CSS
(377)
π XML
(259)
π¦ jQuery UI
(231)
π― Bootstrap
(220)
βοΈ C++
(215)
π °οΈ Angular
(205)
π HTML DOM
(201)
π΄ Redis
(188)
π Web Building
(142)
π Vue.js
(141)
π R
(131)
πΌ Pandas
(124)
ποΈ SQL
(105)
βοΈ Docker
(86)
βοΈ TypeScript
(73)
βοΈ Highcharts
(70)
π AI Agent
(70)
βοΈ React
(68)
π Node.js
(65)
βοΈ Machine Learning
(60)
π Git
(59)
π΅ Go
(58)
π Markdown
(58)
π’ NumPy
(55)
π§ͺ Flask
(54)
βοΈ Scala
(53)
ποΈ SQLite
(52)
π JSTL
(52)
βοΈ VS Code
(51)
π MongoDB
(49)
π Perl
(48)
π Ruby
(47)
π Matplotlib
(47)
βοΈ Uncategorized
(46)
π Swift
(46)
ποΈ PostgreSQL
(46)
βοΈ Data Structures
(46)
π Playwright
(46)
π iOS
(45)
ποΈ MySQL
(44)
βοΈ LangChain
(43)
π FastAPI
(40)
βοΈ Ionic
(38)
π Design Patterns
(37)
βοΈ Eclipse
(37)
π¨ CSS3
(34)
π Lua
(34)
βοΈ Codex
(34)
πΈ Django
(32)
βοΈ OpenCV
(32)
π Rust
(31)
π JSP
(31)
βοΈ Claude Code
(31)
π Pillow
(30)
βοΈ OpenCode
(28)
π AI Skills
(27)
π Flutter
(26)
π Maven
(26)
π¨ Tailwind CSS
(25)
π§ TensorFlow
(25)
π Servlet
(24)
π Dart
(23)
π Assembly
(23)
βοΈ Memcached
(22)
βοΈ SVG
(22)
βοΈ Electron
(22)
π NLP
(22)
π Regex
(21)
π Android
(20)
π£ Kotlin
(19)
π Julia
(19)
π SOAP
(17)
π Selenium
(17)
π PowerShell
(17)
π Sass
(16)
π HTTP
(16)
π Zig
(15)
π AI
(15)
π AJAX
(14)
π Swagger
(14)
βοΈ Scikit-learn
(13)
βοΈ ECharts
(13)
βοΈ Chart.js
(13)
βοΈ Cursor
(13)
βοΈ SciPy
(12)
π RDF
(12)
π Ollama
(12)
π Next.js
(12)
π Plotly Dash
(12)
π JSON
(11)
π RESTful API
(11)
π WSDL
(9)
βοΈ CMake
(8)
π Firebug
(7)
π Nginx
(6)
βΈοΈ Kubernetes
(6)
π Jupyter
(6)
π LaTeX
(4)
π UniApp
(4)
ποΈ SQL Server
(1)