C++将时间格式转换成秒数
#include <stdio.h>
#include <time.h>
#include <string.h>
#include <stdlib.h>
time_t convert_str_to_tm(char * str_time)
{
struct tm tt;
memset(&tt,0,sizeof(tt));
tt.tm_year=atoi(str_time)-1900;
tt.tm_mon=atoi(str_time+5)-1;
tt.tm_mday=atoi(str_time+8);
tt.tm_hour=atoi(str_time+11);
tt.tm_min=atoi(str_time+14);
tt.tm_sec=atoi(str_time+17);
return mktime(&tt) + 28800;//28800是一个偏差。。加上这个。。刚好等于PHP的strtotime
}
int main()
{
char str_time[64] = "2011-12-31 11:43:07";
printf("%d\n", convert_str_to_tm(str_time));
return 0;
}
C++将时间格式转换成秒数的更多相关文章
- Java之格林威治时间格式转换成北京时间格式
Java之格林威治时间格式转换成北京时间格式 package com.mtons.mblog; import java.text.ParseException; import java.text.Si ...
- C#返回时间格式转换成 js 字符串
在.net 中,调用 post 或者 get和后台通信时,如果有时间返回信息,后台返回的时间信息一般是这样格式:Thu Jul 9 23:14:53 UTC+0800 2015,那么要在前台显示就会有 ...
- 将json的时间格式转换成正常的时间格式
/** * 对Date的扩展,将 Date 转化为指定格式的String * 月(M).日(d).12小时(h).24小时(H).分(m).秒(s).周(E).季度(q) 可以用 1-2 个占位符 * ...
- 时间格式转换成JUN.13,2017
SimpleDateFormat sdf = new SimpleDateFormat("MMM.dd,yyyy", Locale.ENGLISH); String negotia ...
- java/python中获取当前系统时间,并与字符串相互转换格式,或者转化成秒数,天数等整数
java转换成秒数 Date类有一个getTime()可以换回秒数,例如: public class DateToSecond { public static void main(String[] a ...
- Swift3 根据秒数获取视频时长(转换成00:00:00时间格式)以及将时长转换成秒
直接代码了: /// 秒转换成00:00:00格式 /// /// - Parameter secounds: <#secounds description#> /// - Returns ...
- 转换GMT秒数为日期时间格式-Delphi源码
转换GMT秒数为日期时间格式-Delphi源码.收藏最近在写PE分析工具的时候,需要转换TimeDateStamp字段值为日期时间格式,这是Delphi的源码. //把GMT时间的秒数转换成日期时间格 ...
- python时间时分秒与秒数的互相转换
受到Unix时间戳的启发,我发现时间转成秒数后会非常好处理,在程序当中不再是以字符串的形式处理,不管时间的加减还是获取随机的时间点都变得非常方便, 如果有需要,也很容易转换成需要的时间格式. 一:时间 ...
- Linux下时间格式转换及获取方法
Linux下使用clock_gettime给程序计时 #include <stdio.h> #include <unistd.h> #include <stdlib.h& ...
随机推荐
- python2中urllib2模块带cookies使用方法
#!/usr/bin/python # coding=utf-8 #############方式1######################### import urllib2 cookie = & ...
- cookie实现用户登录验证
cookie实现用户登录验证 1, INSTALLED_APPS中注册app03 2,在主程序中新建映射关系到app3的url中 from django.conf.urls import url,in ...
- CSS_常见布局
1.一列布局——常用于网站首页. html: <div class="top"></div> <div class="main"& ...
- flask之分页插件的使用、添加后保留原url搜索条件、单例模式
本篇导航: flask实现分页 添加后保留原url搜索条件 单例模式 一.flask实现分页 1.django项目中写过的分页组件 from urllib.parse import urlencode ...
- 开源MSSQL Express Profile 文件
https://files.cnblogs.com/files/mqingqing123/ExpressProfile.rar
- jquery-卡片翻转
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- Compiler Error: Function call with parameters that may be unsafe
如下的代码: #include <stdio.h> #include <string> #include <algorithm> #include <cass ...
- dagger2 重点笔记
官方架构例子,里面有个dagger2的结合的例子 https://github.com/googlesamples/android-architecture https://google.github ...
- KADEMLIA算法
一.概述 基于异或距离算法的分布式散列表(DHT), 实现了去中心化的信息存储于查询系统: Kademlia将网络设计为具有160层的二叉树,树最末端的每个叶子看作为节点,节点在树中的位置由同样是16 ...
- Mathematica新特性Inactive, 求解复杂微分方程
Inactive阻止函数的计算, 求解微分方程有奇效 Block[{Integrate = Inactive[Integrate]}, DSolve[((H - h0)^(7/5) P0 (T - c ...