日期/时间转换:字符串重新presentation到time_t的 [英] Date/time conversion: string representation to time_t

查看:111
本文介绍了日期/时间转换:字符串重新presentation到time_t的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是转换一个日期字符串,格式为MM-DD-YY HH:MM:SS的最佳方式,到 time_t的用C或C ++价值?

What's the best way to convert a date string, formatted as "MM-DD-YY HH:MM:SS", to a time_t value in either C or C++?

推荐答案

使用 strptime()时解析成结构TM ,然后用 mktime()根据转换为 time_t的

Use strptime() to parse the time into a struct tm, then use mktime() to convert to a time_t.

这篇关于日期/时间转换:字符串重新presentation到time_t的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆