将日期格式Www-Mmm-dd hh:mm:ss yyyy转换为c++中的dd hh:mm:ss字符串
convert date format Www Mmm dd hh:mm:ss yyyy to dd hh:mm:ss string in c++
我想转换日期格式"Www-Mmm-dd hh:mm:ss-yyyy",并仅将"dd hh:mm:ss"复制到c++中的字符串中
到目前为止,我一直在字符串,结果是:
char str[255];
char str1[255];
int y = 0;
int i;
time_t timer;
timer = GetTickCount();
strcpy(str, ctime(&timer));
sendBuff[strlen(str) - 1] = ' '; //to remove the new-line from the created string
//to copy from the string the exact Time Without Date from the struct of Www Mmm dd hh:mm:ss yyyy - will take only hh:mm:ss
for (i = 11; i < 19; i++, y++)
strcpy(&str1[y], &str[i]);
Joachim使用substr 建议的代码如下所示
std::string temp = str.substr(11, 9); //from 11the place copy next 9 characters
strcpy(str1, temp.c_str());
相关文章:
- 如何在C++中将 chrono::秒转换为 HH:MM:SS 格式的字符串?
- 如何从远程 SFTP 服务器获取 HH-MM-SS 时间戳格式的文件列表
- 将 hh:mm:ss.zzz 时间 QString 转换为毫秒的单行函数?
- 格式化时间 c++ dd/mm/yyyy hh:ss.
- 如何在C++中将秒更改为 HH:MM:SS 格式?
- 如何以"hh:mm:ss"格式读取C ++中的HH,MM和SS
- 从用户那里获取"yyyy/mm/dd, hh:mm"形式的日期输入并验证C++中的日期?
- 在 C++11 中表示日内时间 HH:MM:SS 的最佳方法是什么?
- C - 用STD :: difftime编写调度程序 - 如何在白天检查时间(HH:MM:SS)
- 以 hh:mm 格式添加时间,C++
- 如何将EPOCH时间转换为时间格式(hh:mm)
- 将字符串"DDMMYY HH:MM"的格式设置为"YY-MM-DD HH:MM"
- C++字符串 DD:HH:MM:SS 到整数数据类型
- 将军事时间转换为标准格式(HH:MM)并以标准格式计算平均值.三个问题
- 时间格式 HH:MM:SS 输入
- 将日期格式Www-Mmm-dd hh:mm:ss yyyy转换为c++中的dd hh:mm:ss字符串
- MM:hh:MM时间,使用c++
- 如何将CFAbsoluteTime转换为YYYY-MM-DD HH:MM:SS格式?
- 两个时间之间经过的时间,格式为24小时hh:mm:ss
- 发送信号在特殊时间,如hh:mm与Qt