C语言 strftime 格式化显示日期时间 时间戳
C/C++程序中需要程序显示当前时间,可以使用标准函数strftime。
函数原型:size_t strftime (char* ptr, size_t maxsize, const char* format,const struct tm* timeptr );
代码示例:
#include <stdio.h>
#include <time.h> int main ()
{
time_t rawtime;
struct tm * timeinfo;
char buffer []; time (&rawtime);
printf("%ld\n", rawtime); timeinfo = localtime (&rawtime);
strftime (buffer,sizeof(buffer),"Now is %Y/%m/%d %H:%M:%S",timeinfo);
printf("%s\n", buffer); return ;
}
代码输出:

格式化时间说明表:

更多资源见如下链接:
cplusplus strftime:http://www.cplusplus.com/reference/ctime/strftime/?kw=strftime
http://www.cnblogs.com/Wiseman/archive/2005/10/24/260576.html
C语言 strftime 格式化显示日期时间 时间戳的更多相关文章
- LaTeX去掉默认显示日期时间
LaTeX去掉默认显示日期时间: \date{}
- 在Jquery里格式化Date日期时间数据
在Jquery里格式化Date日期时间数据: $(function(){ //当前时间格式化yyyy-MM-dd HH:mm:ss alert(timeStamp2String(new Date(). ...
- JAVA中String.format的用法 格式化字符串,格式化数字,日期时间格式化,
1.对整数进行格式化:%[index$][标识][最小宽度]转换方式 我们可以看到,格式化字符串由4部分组成,其中%[index$]的含义我们上面已经讲过,[最小宽度]的含义也很好理解, ...
- 使用Python将字符串转换为格式化的日期时间字符串
我正在尝试将字符串“20091229050936”转换为“2009年12月29日(UTC)” >>>import time >>>s = time.strptime ...
- 软件素材---C/C++格式化显示当前时间--标准函数strftime
函数原型:size_t strftime (char* ptr, size_t maxsize, const char* format,const struct tm* timeptr ); 头文件: ...
- C语言字符串格式化显示
符号 作用 ────────────────────────── %d 十进制有符号整数 %i 输 ...
- js显示日期时间(集锦)
1.最简单的时钟显示 <div id="time"></div> <script> setInterval(); </script>
- DATE_FORMAT() 函数用于以不同的格式显示日期/时间数据。
DATE_FORMAT(date,format) format参数的格式有 %a 缩写星期名 %b 缩写月名 %c 月,数值 %D 带有英文前缀的月中的天 %d 月的天,数值(00-31) %e 月的 ...
- IntelliJ IDEA调试时,格式化显示日期变量
格式化前: 格式化后: new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(this); 入门常用知识: Ct ...
随机推荐
- 洛谷P3605 [USACO17JAN] Promotion Counting 晋升者计数 [线段树合并]
题目传送门 Promotion Counting 题目描述 The cows have once again tried to form a startup company, failing to r ...
- 在控制台连接oracle
Microsoft Windows [版本 6.1.7601]版权所有 (c) 2009 Microsoft Corporation.保留所有权利. C:\Users\lijt>sqlplus ...
- SQL注入备忘录
备忘录(一) 拿起小本本记下常考知识点. 常用连接词 and && %23%23 且 or || %7c%7c 或 xor 非 Access 数据库: 只能爆破表名.列名获取数据.无法 ...
- 层级目录结构的Makefile递归编译方法
层级目录结构的Makefile编写方法. 层级目录结构的Makefile编写方法. 0.前言 1.如何编译整个工程 2.过滤每层不需要编译的目录 3将所有输出文件定向输出. 0.前言 假如现在有这样一 ...
- APPKIT打造稳定、灵活、高效的运营配置平台
一.背景 美团App.大众点评App都是重运营的应用.对于App里运营资源.基础配置,需要根据城市.版本.平台.渠道等不同的维度进行运营管理.如何在版本快速迭代过程中,保持运营资源能够被高效.稳定和灵 ...
- Moo University - Financial Aid POJ 2010 优先队列(最大堆)
题目:http://poj.org/problem?id=2010 题目大意: 奶牛上大学.因为经济问题,每头奶牛都需要一定的补助需求,学校会提供一定的资金用于补助 每头牛都有自己的分数,学校招收的名 ...
- python functools.wraps
我们在使用装饰器的时候,有些函数的功能会丢失,比如func.__name__,func.__doc__,func.__module__ 比如下面这个例子: In [16]: def logged(fu ...
- tftp协议
<前言> 嵌入式开发是一个交叉开发的模式,需要将宿主机上的文件烧写到目标机上. 方式: JTAG USB 串口 网络 <tftp下载> 首先需要将宿主机架成一个TFTP的服务器 ...
- Reading lists for new LISA students(转)
Research in General How to write a great research paper Basics of machine learning http://www.iro.um ...
- Codeforces Round #463
A - Palindromic Supersequence /* 题目大意:给出一个串,构造一个包含该串的回文串 */ #include <cstdio> #include <alg ...