如何在按钮点击事件中获取当前系统时间,并以(可能)指定的格式(例如:YYYY-MM-DD-HH-MM-SS)将其分配给- (IBAction)sendPressed {
if([youtubeurl.text isEqualToString:@""]) {
//if it doesnt have value
NSLog(@"no youtube clip");
youtubelink = @"";
}
else{
//if youtube url has been entered
NSLog(@"youtube clip found");
completeurl = youtubeurl.text;
youtubelink = [completeurl substringFromIndex:16];
}
}
变量?
我正在使用Visual Studio 2013。
答案 0 :(得分:0)
示例代码:
//#include <time.h>
time_t rawtime;
struct tm * timeinfo;
time(&rawtime);
timeinfo = localtime(&rawtime);
//The years are since 1900 according the documentation, so add 1900 to the actual year result.
printf("Date: %d/%d/%d Time: %d:%d:%d",timeinfo->tm_year + 1900, timeinfo->tm_mon, timeinfo->tm_mday, timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);