一个简单返回当前北京时间的小程序
#include <time.h>
void main()
{
unsigned long now=time(NULL);
unsigned long day=24*60*60, h=0, m=0, s=0;
while(now>day)
now-=day;
printf("现在时间(北京):\n");
if(now==day || now==0)
printf("00 : 00 : 00");
else
{
h=now/(60*60);
now=now-h*60*60;
m=now/60;
now=now-m*60;
s=now;
printf("%-lu : %-lu : %-lu", h+8, m, s);
}
printf("\n");
}