(C++) std::localtime

January 10, 2018 · View on GitHub

 

 

 

 

 

(C++) std::localtime

 

std::localtime is an STL time function to obtain the local date and time.

 

 

 

 

 

Example: GetToday

 


#include <ctime> #include <iostream> int main () {   std::time_t my_time;   std::time( &my_time );   const std::tm * const time_and_date = std::localtime(&my_time);   std::cout << std::asctime(time_and_date); }

 

Today's screen output:

 


Sun Aug 8 09:01:41 2010

 

 

 

 

 

 

Contents

  1. 1Example: GetToday
  2. 2#include int main () { std::time_t my_time; std::time( &#x26;my_time ); const std::tm * const time_and_date = std::localtime(&#x26;my_time); std::cout #include &#x3C;ctime> #include &#x3C;iostream> int main () { std::time_t my_time; std::time( &#x26;my_time ); const std::tm * const time_and_date = std::localtime(&#x26;my_time); std::cout &#x3C;&#x3C; std::asctime(time_and_date); }
  3. 3Sun Aug 8 09:01:41 2010