Chinaunix首页 | 论坛 | 博客
  • 博客访问: 356840
  • 博文数量: 109
  • 博客积分: 45
  • 博客等级: 民兵
  • 技术积分: 1920
  • 用 户 组: 普通用户
  • 注册时间: 2012-11-19 11:17
个人简介

只要活着,就要有目标。

文章分类
文章存档

2013年(109)

我的朋友

分类: LINUX

2013-05-24 16:26:20

    linux 获取当前日期与时间的代码:

    /* ************************************************************************
    *       Filename:  main.c
    *    Description:
    *        Version:  1.0
    *        Created:  2012年06月19日 10时34分55秒
    *       Revision:  none
    *       Compiler:  gcc
    *         Author:  YOUR NAME (),
    *        Company:
    * ************************************************************************/
    #include
    #include
    #include
    #include
    #include
    int main(int argc, char *argv[])
    {
    struct timeval tv;
    char mytime[20] = "";
    gettimeofday(&tv,NULL);
    strftime(mytime,sizeof(mytime),"%Y-%m-%d %T",localtime(&tv.tv_sec));
    printf("Time:%s\n",mytime);
    return 0;
    }
   原文转自Leo Chin博客http://www.cnblogs.com/hnrainll/archive/2012/06/19/2554473.html
阅读(1404) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~