'Timestamp'에 해당되는 글 2건

  1. 2013.02.13 struct timeb example.
  2. 2011.11.30 JavaScript unix timestamp 맛보기.

struct timeb example.

ITWeb/개발일반 2013.02.13 16:37

Reference URL : http://pubs.opengroup.org/onlinepubs/7908799/xsh/systimeb.h.html


sys/timeb.h - additional definitions for date and time


#include <sys/timeb.h>


The <sys/timeb.h> header defines the timeb structure that includes at least the following members:

time_t         time     the seconds portion of the current time
unsigned short millitm  the milliseconds portion of the current time
short          timezone the local timezone in minutes west of Greenwich
short          dstflag  TRUE if Daylight Savings Time is in effect

The time_t type is defined as described in <sys/types.h>.

The header <sys/timeb.h> declares the following as a function which may also be defined as a macro. Function prototypes must be provided for use with an ISO C compiler.

int   ftime(struct timeb *);






ftime(), <time.h>.

[Example Code - timeb.cpp]

#include <stdio.h>

#include <time.h>

#include <sys/timeb.h>

int main () {

    timeb tb;

    ftime( &tb );

    int64_t ts = tb.millitm + (tb.time * 1000);

    printf("tb.time*1000 + tb.millitm is %ld", ts);

    return 0;



g++ timeb.cpp -o timeb

tags : timeb, Timestamp
Trackback 0 : Comment 0

JavaScript unix timestamp 맛보기.

ITWeb/개발일반 2011.11.30 15:08
아래 두개 중에 택 1 하세요.
둘다 정수를 return 해 줍니다.
다만, 차이는 아시죠.. 반올림과 내림이라는거..


[CASE 1]
Math.round((new Date()).getTime() / 1000);

Math.floor((new Date()).getTime() / 1000);

tags : Timestamp
Trackback 0 : Comment 0