随记一个C的时间加减
//Centos6 x86_64
#include <time.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main( int argc, char *argv[] )
{
time_t tmp_time;
struct tm *ptime;
struct tm *tmp;
tmp_time = time(NULL);
if(argv[1]==0)
{
printf("Input Value Null!\n");
printf("Example:\n");
printf("zz -10 // before 10 minutes\n");
return -1;
}
else
printf("%d\n",atoi(argv[1]));
//ptime = localtime(&tmp_time);
//printf("%d-%d-%d %d:%d:%d\n",(1900+ptime->tm_year),(1+ptime->tm_mon),ptime->tm_mday,ptime->tm_hour,ptime->tm_min,ptime->tm_sec)
;
tmp_time += atoi(argv[1])*60;
tmp = localtime(&tmp_time);
printf("%04d-%02d-%02d %02d:%02d:%02d\n",(1900+tmp->tm_year),(1+tmp->tm_mon),tmp->tm_mday,tmp->tm_hour,tmp->tm_min,tmp->tm_sec);
}
随记一个C的时间加减的更多相关文章
- JAVA时间进行比较和转换,时间加减得到天数
转自:https://blog.csdn.net/iteye_8535/article/details/82246006 JAVA时间进行比较和转换,时间加减得到天数 1. 把时间类型的字符串转为DA ...
- Sql里时间加减
简单的时间加减 DATEADD(dd,-30, GETDATE())) 使用DateADD方法: 参数1:间隔,表示要添加的时间间隔,一天还是一月还是一年 参数2:要加或减的个数,加一年或加一月 参数 ...
- DB2时间函数 实现 时间加减
时间加减:后边记得跟上时间类型如day.HOUR TIMESTAMP ( TIMESTAMP(DEF_TIME)+1 day)+18 HOUR DB2时间函数是我们最常见的函数之一,下面就为您介绍 ...
- js时间比较大小,时间加减
第一种: //时间类比较 startTime= new Date(Date.parse(starttime)); endTime=new Date(Date.parse(endTime)); //进行 ...
- php 时间加减
<?php date_default_timezone_set('PRC'); //默认时区 echo "今天:",date("Y-m-d",time() ...
- php如何在某个时间上加一天?一小时? 时间加减
<?php date_default_timezone_set('PRC'); //默认时区 echo "今天:",date("Y-m-d",time() ...
- mysql时间加减运算
一.MySQL 获得当前日期时间 函数 1.1 获得当前日期 + 时间(date + time) 函数:now() mysql> select now();+———————+| now() |+ ...
- php如何在某个时间上加一天?一小时? 时间加减(转)
<?php date_default_timezone_set('PRC'); //默认时区 echo "今天:",date("Y-m-d",time() ...
- NSDate 时间加减
版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/pearlhuzhu/article/details/26227393 NSDate有个类别,例如以下 ...
随机推荐
- CentOS6.5设备MRBS
//--------------------------------------软件必须安装-----------------------------------// # yum install –y ...
- ubuntu 下舒畅的使用libreoffice
step 1 英语渣的同学.或者对功能栏的一大堆略显专业的单词不敢下手的同学 你须要一个中文汉化包 不用去官网找了,源里就有 sudo apt-get install libreoffice-l10n ...
- HttpWebRequest BeginGetResponse EndGetResponse
private void Button_Click_4(object sender, RoutedEventArgs e) { HttpWebRequest request = HttpWebRequ ...
- Coco2d-x android win7 Python 游戏开发环境的搭建
1:我用的电脑配置 win7 3 核 内存8G 桌面.一直想学习Coco2d 游戏开发,所以,一个星期后,需要找到,最终建立了一个良好的环境 2:我使用的版本号版本号,至于建筑android开发环境略 ...
- Android4.0(Phone)来电过程分析
在开机时.系统会启动PhoneApp类,那是由于在AndroidManifest.xml文件里配置了 <application android:name="PhoneApp" ...
- Building Redis for use on Cygwin(转)
This is the second time I have installed Redis for use on Cygwin in the last several months. It seem ...
- 库函数atoi()的实现
int atoi(const char *nptr); 假设第一个非空格字符存在,是数字或者正负号则開始做类型转换,之后检測到非数字(包含结束符 \0) 字符时停止转换.返回整形数. 否则,返回零. ...
- document.all使用
document.all 一个. document.all它是在页面中的所有元素的集合.例如: document.all(0)一个元素 二. document.all能够推断浏览器是否是IE ...
- FutureTask解析(转)
站在使用者的角度,future是一个经常在多线程环境下使用的Runnable,使用它的好处有两个:1. 线程执行结果带有返回值2. 提供了一个线程超时的功能,超过超时时间抛出异常后返回. 那,怎么实现 ...
- CodeIgniter连接数据库及快速入门
原文:CodeIgniter连接数据库及快速入门 一.数据库配置 CodeIgniter 有一个配置文件让你存放数据库连接值(username:用户名,password:密码,database nam ...