C语言基础:时间转换成字符串 strftime的代码
生活随笔
收集整理的這篇文章主要介紹了
C语言基础:时间转换成字符串 strftime的代码
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
將內容過程中經(jīng)常用的一些內容段做個記錄,下邊內容段是關于C語言基礎:時間轉換成字符串 strftime的內容,希望能對大伙有一些用處。
#include <stdio.h> #include <time.h>int main(void){char buffer[128];time_t current_time;tzset();time(¤t_time);datetime = localtime(¤t_time);strftime(buffer, sizeof(buffer), "%x %X", datetime);printf("Using %%x %%X: %sn", buffer);strftime(buffer, sizeof(buffer), "%A %B %m, %Y", datetime);printf("Using %%A %%B %%m %%Y: %sn", buffer);strftime(buffer, sizeof(buffer), "%I:%M%p", datetime);printf("Using %%I:%%M%%p: %sn", buffer);return 1;}輸出結果Using %x %X: 09/09/12 18:10:33 Using %A %B %m %Y: Sunday September 09, 2012 Using %I:%M%p: 06:10PM轉載于:https://blog.51cto.com/14137986/2346463
總結
以上是生活随笔為你收集整理的C语言基础:时间转换成字符串 strftime的代码的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 警惕!这7件事情千万不要发生你身上-来自
- 下一篇: UVA 220 Othello