asctime()

时间文本格式

clock()

返回自程序开始运行所经过的时间

ctime()

返回特定格式时间

difftime()

两时刻的间隔

gmtime()

返回指向当前格林威治时间的指针

localtime()

返回指向当前时间的指针

mktime()

返回指定时间的日历格式

strftime()

返回日期和时间的单个元素

time()

返回系统的当前日历时间


asctime

语法:

 
  #include <time.h>
  char *asctime( const struct tm *ptr );

功能: 函数将ptr所指向的时间结构转换成下列字符串:

    day month date hours:minutes:seconds year\n\0

例如:

    Mon Jun 26 12:03:53 2000

相关主题:
localtime(), gmtime(), time(), and ctime().


clock

语法:

 
  #include <time.h>
  clock_t clock( void );

功能:函数返回自程序开始运行的处理器时间,如果无可用信息,返回-1。 转换返回值以秒记, 返回值除以CLOCKS_PER_SECOND. (注: 如果编译器是POSIX兼容的, CLOCKS_PER_SECOND定义为1000000.)

相关主题:
time(),
asctime(), and ctime().


ctime

语法:

 
  #include <time.h>
  char *ctime( const time_t *time );

功能:函数转换参数time为本地时间格式:

    day month date hours:minutes:seconds year\n\0

ctime() 等同

    asctime( localtime( tp ) );

相关主题:
localtime(), gmtime(), time(), and asctime().


difftime

语法:

 
  #include <time.h>
  double difftime( time_t time2, time_t time1 );

功能:函数返回时间参数time2time1之差的秒数表示。

相关主题:
localtime(), gmtime(), time(), and asctime().


gmtime

语法:

 
  #include <time.h>
  struct tm *gmtime( const time_t *time );

功能:函数返回给定的统一世界时间(通常是格林威治时间),如果系统不支持统一世界时间系统返回NULL。 警告!

相关主题:
localtime(), time(), and asctime().


localtime

语法:

 
  #include <time.h>
  struct tm *localtime( const time_t *time );

功能:函数返回本地日历时间。警告!

相关主题:
gmtime(), time(), and asctime().


mktime

语法:

 
  #include <time.h>
  time_t mktime( struct tm *time );

功能:函数转换参数time 类型的本地时间至日历时间,并返回结果。如果发生错误,返回-1。

相关主题:
time(),
gmtime(), asctime(), and ctime().


strftime

语法:

 
  #include <time.h>
  size_t strftime( char *str, size_t maxsize, const char *fmt, struct tm *time );

功能:函数按照参数fmt所设定格式将time类型的参数格式化为日期时间信息,然后存储在字符串str中(至多maxsize 个字符)。用于设定时间不同类型的代码为:

代码

含义

%a

星期的缩略形式

%A

星期的完整形式

%b

月份的缩略形式

%B

月份的完整形式

%c

月份的缩略形式

%d

月中的第几天(1-31)

%H

小时, 24小时格式 (0-23)

%I

小时, 12小时格式  (1-12)

%j

年中的第几天(1-366)

%m

月份 (1-12). Note: 某些版本的Microsoft Visual C++ 可能使用取值范围0-11.

%M

分钟(0-59)

%p

本地时间的上午或下午(AM or PM)

%S

秒钟(0-59)

%U

年中的第几周,星期天是一周的第一天

%w

星期几的数字表示(0-6, 星期天=0)

%W

一年中的第几周,星期天是一周的第一天

%x

标准日期字符串

%X

标准时间字符串

%y

年(0-99)

%Y

用CCYY表示的年(如:2004)

%Z

时区名

%%

百分号

函数strftime()返回值为处理结果字符串str中字符的个数,如果发生错误返回零。

相关主题:
time(),
localtime(), and gmtime().


time

语法:

 
  #include <time.h>
  time_t time( time_t *time );

功能: 函数返回当前时间,如果发生错误返回零。如果给定参数time ,那么当前时间存储到参数time中。

相关主题:
localtime(), gmtime(), strftime(), ctime(),

C++ 第十课:标准c时间与日期函数的更多相关文章

  1. 标准c时间与日期函数

    标准c时间与日期函数 asctime 语法:     #include <time.h>   char *asctime( const struct tm *ptr ); 功能: 函数将p ...

  2. Python 关于时间和日期函数使用 -- (转)

    python中关于时间和日期函数有time和datatime   1.获取当前时间的两种方法: import datetime,time now = time.strftime("%Y-%m ...

  3. lua的时间和日期函数

    lua的时间和日期函数 -- ::| 分类: Lua | 标签:lua 时间 函数 |举报|字号 订阅 下载LOFTER客户端 --获取当前的时间戳,单位是秒. time=os.time(); pri ...

  4. mysql 中时间和日期函数应用

    一.MySQL 获得当前日期时间 函数 1.1 获得当前日期+时间(date + time)函数:now() mysql> select now(); +-------------------- ...

  5. [转]详细的mysql时间和日期函数

    这里是一个使用日期函数的例子.下面的查询选择了所有记录,其date_col的值是在最后30天以内: mysql> SELECT something FROM table WHERE TO_DAY ...

  6. mysql 中 时间和日期函数

    From: http://www.cnblogs.com/redfox241/archive/2009/07/23/1529092.html 一.MySQL 获得当前日期时间 函数 1.1 获得当前日 ...

  7. PHP之时间和日期函数

    // 时间日期函数 Time <?php date_default_timezone_set('UTC'); // 获取当前时间的时间戳 $time0 = mktime(); $time1 = ...

  8. python 时间及日期函数

    本人最近新学python ,用到关于时间和日期的函数,经过一番研究,从网上查找资料,经过测试,总结了一下相关的方法. import timeimport datetime '''时间转化为时间戳: 2 ...

  9. php第五节(字符串函数和时间、日期函数)

    <?php //查找字符串函数 // strpos() 查找字符第一次出现的位置 重点区分大小写 //stripos — 查找字符串首次出现的位置(不区分大小写) //strrpos — 计算指 ...

随机推荐

  1. Java Deadlock Example and How to analyze deadlock situation

    source:http://www.journaldev.com/1058/java-deadlock-example-and-how-to-analyze-deadlock-situation De ...

  2. 基于Python的卷积神经网络和特征提取

    基于Python的卷积神经网络和特征提取 用户1737318发表于人工智能头条订阅 224 在这篇文章中: Lasagne 和 nolearn 加载MNIST数据集 ConvNet体系结构与训练 预测 ...

  3. RAISR: rapid and accurate image super resolution

      准确地说,RAISR并不是用来压缩图像的,而是用来upsample图像的. 众所周知,图片缩小到半分辨率后,在拉回原大小,会出现强烈的锯齿.从80年代开始就有很多super sampling的方法 ...

  4. Kafka学习入门

    最近工作中用到了两个很给力的项目,一个是Kafka,一个是Strom.本着自我学习并方便他人的目的,我会将我觉得比较有用的英文文档翻译在此(保留系统专有名词不作翻译). 1kafka介绍 在流式计算中 ...

  5. Windows7安装CodeTyphon

    WARNING 1: On windows (XP, Vista and Win7), you must install this software as user with administrato ...

  6. 读书笔记,《深入理解java虚拟机》,第三章 垃圾收集器与内存分配策略

    要实现虚拟机,其实人们主要考虑完成三件事情: 第一,哪些内存需要回收: 第二,什么时候回收: 第三,如何回收. 第二节,对象已死吗    垃圾收集其实主要是针对java堆里面的数据来说的,传统的垃圾收 ...

  7. Unique Binary Search Trees II leetcode java

    题目: Given n, generate all structurally unique BST's (binary search trees) that store values 1...n. F ...

  8. 必须记住的 30 类 CSS 选择器

    大概大家读知道`id`,`class`以及`descendant`选择器,并且整体都在使用它们,那么你正在错误拥有更大级别的灵活性的选择方式.这篇文章里面提到的大部分选择器都是在CSS3标准下的,所以 ...

  9. Wide and Deep Learning Model

    https://blog.csdn.net/starzhou/article/details/78845931 The Wide and Deep Learning Model(译文+Tensorlf ...

  10. 基于PU-Learning的恶意URL检测

    https://xz.aliyun.com/t/2190 Ya-Lin Zhang, Longfei Li, Jun Zhou, Xiaolong Li, Yujiang Liu, Yuanchao ...