如何在C++中保存带有日期和时间的图像文件名?
How to save an image filename with Date & time in C++?
我正在使用代码保存相机中的图像,但我需要使用当前拍摄图像的日期和时间保存文件名。我该怎么做?我已经从互联网上尝试了许多不同的代码,但我总是遇到很多错误,编程不是我的强项。任何建议或帮助将不胜感激。这是代码:https://github.com/stereolabs/zed-save-depth/blob/master/src/main.cpp
您可以使用:
#include <time.h>
为了时间。要获取当前时间:
time_t current_time = clock();
要获取当前日期,您可以使用:
struct tm *localtime(const time_t *time);
它返回一个本地时间的结构,如下所示:
struct tm {
int tm_sec; // seconds of minutes from 0 to 61
int tm_min; // minutes of hour from 0 to 59
int tm_hour; // hours of day from 0 to 24
int tm_mday; // day of month from 1 to 31
int tm_mon; // month of year from 0 to 11
int tm_year; // year since 1900
int tm_wday; // days since sunday
int tm_yday; // days since January 1st
int tm_isdst; // hours of daylight savings time
}
相关文章:
- 如何找到两个日期之间的时间差异(以秒和纳秒为单位)?
- 使用 C++将时间戳转换为格式化的日期时间
- 从具有不同曝光时间的图像中获取HDR图像
- C++代码的 C# 日期时间等效项是什么?
- Rcpp/C++/R:比较日期时间矢量与日期时间时出错(错误:"运算符>"的不明确重载)
- 如何将毫秒的日期时间字符串转换为 UNIX 时间戳
- 扩展中的日期时间对象方法C++问题
- 将DateTime字符串分为C 的日期时间
- C++ Poco SQL 查询不返回具有'between'和'and'日期时间绑定的结果
- 快速将带有时区的日期时间字符串转换为 UNIX 时间戳(C++)
- 从C 的时间戳提取日期时间戳
- 标准::get_time 中的日期时间格式
- 生成包含分数和时区的完整 iso 日期时间表示字符串
- 通过 ODBC C++将带有日期时间的记录插入 SQL Server 2014 的问题
- 如何通过time_t更改日期和时间的格式
- 我如何解析包括分数时间的日期时间字符串
- Qt ISODate格式化的日期/时间,包括时区
- 如何在当前日期/时间之后命名我创建的文本文件
- 在C++11中解析毫秒日期时间的最佳方法是什么
- 如何在C++中保存带有日期和时间的图像文件名?