'밀리세컨드'에 해당되는 글 1건

  1. 2018.12.10 C/C++ | 밀리세컨드 까지 뽑아오기
#include <cstdio>
#include <cstdlib>​
#include <sys/timeb.h>​
#include <ctime>
#include <ctime>


struct timeb timer_msec;
ftime(&timer_msec);

tm *ts = localtime(&timer_msec.time);

int year = ts->tm_year + 1900;
int month = ts->tm_mon + 1;
int day = ts->tm_mday;
int hour = ts->tm_hour;
int min = ts->tm_min;
int sec = ts->tm_sec;
int milli = timer_msec.millitm;




/////////////////////////////
c ++

#include <sys/time.h>
#include <chrono>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <iostream>​

auto time = std::chrono::system_clock::now();
auto mill = std::chrono::duration_cast<std::chrono::milliseconds>(time.time_since_epoch());

long long currentTimeMillis = mill.count();
int msc = currentTimeMillis % 1000;
long nowTime = currentTimeMillis / 1000;

tm *ts = localtime(&nowTime);

int year = ts->tm_year + 1900;
int month = ts->tm_mon + 1;
int day = ts->tm_mday;
int hour = ts->tm_hour;
int min = ts->tm_min;
int sec = ts->tm_sec;
char temp[1024] = { '\0' };
sprintf(temp, "%04d-%02d-%02d %02d:%02d:%02d.%d   \n",  year, month, day, hour, min, sec, msc);



Posted by 선화
이전버튼 1 이전버튼

블로그 이미지
선화

공지사항

Yesterday
Today
Total

달력

 « |  » 2024.3
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

글 보관함