标题: ARM板的RTC检测 [打印本页] 作者: uperrua 时间: 2019-8-1 11:04 标题: ARM板的RTC检测 % n5 ?- h# d" B k1 f6 {8 x
9 N/ t1 P& O! }3 s$ K( l' Q
& O+ }4 I# y5 J2 S
#include <stdio.h>
#include <time.h>
// 可以测试ARM板的RTC是不是好的
void GetLocalTime(void)
{
time_t now;
struct tm *timenow;
time(&now);
timenow = localtime(&now);
printf("Local time is = %s", asctime(timenow));
}
int main(void)
{
GetLocalTime();
return 0;
}0 W' [0 h& q$ c' S3 g3 ]6 n/ ^, W
) _" v% s& `$ ^7 n5 _
% P6 R) U# Y/ z
: @9 K) o- P/ ] 7 H4 b7 P1 S I @1 n4 J/ v5 b . x' r x& ~" Eroot@libang-virtual-machine:~/test/test# gcc local_time.c / Q' G. Z' M! X0 X# u* w g4 S
root@libang-virtual-machine:~/test/test# ./a.out 4 d) j( E2 I6 M
Local time is = Tue Aug 23 14:53:16 20169 H5 r# N4 z$ q
) F B# m8 g3 F. p/ Z
: ?3 K' n% N( f; L0 [) w! ~7 ]% g& c3 j/ q3 }- v. o' c
, @; p+ @# F0 t2 V