close
直接看code
struct tm local_time_st;
char buf[256];
time_t current_time = time(NULL);
// clear buffer
memset(buf, 0, 256);
// get struct tm
localtime_r(¤t_time, &local_time_st);
// format the string
sprintf(buf, "offset %+03d:%02d",
local_time_st.tm_gmtoff / (60 * 60),
abs(local_time_st.tm_gmtoff % (60 * 60)) / 60); // tm_gmtoff is seconds
全站熱搜
留言列表