h**o 发帖数: 548 | 1 suppose the I get a http response with header:
"Expires: Mon, 26 Jul 2009 05:00:00 GMT", I need to converts it to timestamp
of the computer's current time?
Thanks. | m*****e 发帖数: 4193 | 2 ctime
timestamp
【在 h**o 的大作中提到】 : suppose the I get a http response with header: : "Expires: Mon, 26 Jul 2009 05:00:00 GMT", I need to converts it to timestamp : of the computer's current time? : Thanks.
| h**o 发帖数: 548 | 3 I think you want me to use strptime(). and I can now get the timestamp by
using
strptime("18 Oct 2008 14:11:00", "%d %b %Y %H:%M:%S", &tm).
but how do I convert GMT time "18 Oct 2008 14:11:00 GMT"to my local
timestamp, no matter where my local computer locates?
【在 m*****e 的大作中提到】 : ctime : : timestamp
| h**o 发帖数: 548 | 4 我编了一个,没你那么复杂:但不知为何少了一个小时. 我市pacific time, 应该与
GMT 查7小时,但timezone 愣是给减了8小时. 我已经写 tm.tm_isdst = 1 了:
suppose GMT_str = "18 Oct 2008 14:11:00"
extern long timezone;
time_t GMT_2_localtimestamp(char* GMT_str){
struct tm tm;
strptime(GMT_str, "%d %b %Y %H:%M:%S", &tm);
tm.tm_isdst = 1;
time_t gm_t = mktime(&tm);
tzset();
gm_t -= timezone;
return gm_t;
} |
|