Chinaunix首页 | 论坛 | 博客
  • 博客访问: 9147069
  • 博文数量: 1726
  • 博客积分: 12961
  • 博客等级: 上将
  • 技术积分: 19850
  • 用 户 组: 普通用户
  • 注册时间: 2009-01-09 11:25
个人简介

偷得浮生半桶水(半日闲), 好记性不如抄下来(烂笔头). 信息爆炸的时代, 学习是一项持续的工作.

文章分类

全部博文(1726)

文章存档

2024年(2)

2023年(26)

2022年(112)

2021年(217)

2020年(157)

2019年(192)

2018年(81)

2017年(78)

2016年(70)

2015年(52)

2014年(40)

2013年(51)

2012年(85)

2011年(45)

2010年(231)

2009年(287)

分类: Android平台

2016-10-21 19:04:54


点击(此处)折叠或打开

  1. #include <stdlib.h>
  2. #include <time.h>
  3. #include <string.h>
  4. #include <stdio.h>
  5. #include <sys/time.h>

  6. //char *strptime(const char *s, const char *format, struct tm *tm);
  7. //size_t strftime(char *s, size_t max, const char *format, const struct tm *tm);


  8. int main()
  9. {
  10.     char outstr[128]={0};
  11.     time_t t;
  12.     struct tm *tmp;

  13.     t = time(NULL);
  14.     tmp = localtime(&t);

  15.     strftime(outstr, sizeof(outstr), "%a, %d %b %Y %H:%M:%S %Z", tmp);
  16.     printf("%s.\n",outstr);
  17.     //return 0;
  18.     


  19.     const char date[] = "Fri, 21 Oct 2016 20:06:50 GMT";
  20.     strptime(date, "%a, %d %b %Y %H:%M:%S %Z", tmp);
  21.     t = mktime(tmp);
  22.     t += (8*60*60);
  23.     tmp = localtime(&t);

  24.     strftime(outstr, sizeof(outstr), "%Y-%m-%d %H:%M:%S %Z", tmp);
  25.     printf("%s.\n",outstr);

  26. }

阅读(1264) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~