Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

get current date in c++

#include <ctime>
#include <iostream>

int main() {
    std::time_t t = std::time(0);   // get time now
    std::tm* now = std::localtime(&t);
    std::cout << (now->tm_year + 1900) << '-' 
         << (now->tm_mon + 1) << '-'
         <<  now->tm_mday
         << "
";
}
 
PREVIOUS NEXT
Tagged: #current #date
ADD COMMENT
Topic
Name
2+4 =