c/c++ linux下获取时间


#include<sys/time.h>
/*
struct timeval
  {
    __time_t tv_sec;		 Seconds.  秒位部分
    __suseconds_t tv_usec;	 Microseconds.  微秒位部分
  };
*/

void fn(){
    struct timeval now;
    gettimeofday(&now, NULL); //获取从1970年1月1日到现在的时间
    cout<<"当前的时间是"<<(long)now.tv_sec*1000 + (long)now.tv_usec/1000<<"毫秒"<<endl;
}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM