Created
February 19, 2018 04:12
-
-
Save sailfish009/9cffd8bc21d87819f401c07335cc5ab1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unsigned int get_current_date() | |
{ | |
time_t currentTime; | |
tm local_Time; | |
time(¤tTime); // Get the current time | |
localtime_s(&local_Time, ¤tTime); // Convert the current time to the local time | |
int Year = local_Time.tm_year + 1900; | |
int Month = local_Time.tm_mon + 1; | |
int Day = local_Time.tm_mday; | |
char tmp_str[1024]; | |
sprintf_s(tmp_str, sizeof(tmp_str), "%04d%02d%02d", Year, Month, Day); | |
std::string str(tmp_str); | |
unsigned int current_date = std::stoul(str, nullptr, 16); | |
printf("date: %s\n", str.c_str()); | |
printf("date: 0x%08x\n", current_date); | |
return current_date; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment