php time to systemtime
来源:互联网 发布:丙肝化验单正常数据 编辑:程序博客网 时间:2024/06/07 13:29
收到远端php送来的一个时间值, 为一串数字. 查了下,好像是使用 php的 time() 或 date() 生成的.
整理了一个函数, 将该时间戳转成 SYSTEMTIME.
因为我知道该时间值的大概实际日期,转换后感觉还靠谱, 像是正确的时间值.
函数:
/** struct tm declare tm_sec Seconds after minute (0 – 59). tm_min Minutes after hour (0 – 59). tm_hour Hours since midnight (0 – 23). tm_mday Day of month (1 – 31). tm_mon Month (0 – 11; January = 0). tm_year Year (current year minus 1900). tm_wday Day of week (0 – 6; Sunday = 0). tm_yday Day of year (0 – 365; January 1 = 0). tm_isdst Always 0 for gmtime. */ BOOL php_time_2_systemtime(long lPhpTime, SYSTEMTIME* pst) { BOOL bRc = FALSE; time_t tmt = -1; struct tm* pGmt = NULL; do { if (NULL == pst) break; tmt = lPhpTime; pGmt = gmtime(&tmt); if (NULL == pGmt) break; pst->wYear = 1900 + pGmt->tm_year; pst->wMonth = 1 + pGmt->tm_mon; pst->wDay = pGmt->tm_mday; pst->wHour = pGmt->tm_hour; pst->wMinute = pGmt->tm_min; pst->wSecond = pGmt->tm_sec; pst->wDayOfWeek = pGmt->tm_wday; bRc = TRUE; } while (0); return bRc; }
函数的使用:
if (NULL != m_p_ctrl_time) { if (ns_base::php_time_2_systemtime(_ttol(str_time.c_str()), &st)) { strTemp = ns_base::StringFormatV(L"%d-%d-%d", st.wYear, st.wMonth, st.wDay); } else { strTemp = L""; } m_p_ctrl_time->SetText(strTemp.c_str()); }
0 0
- php time to systemtime
- helper function: compare two SYSTEMTIME, to get time span
- SYSTEMTIME
- SYSTEMTIME
- 22 Open Source PHP Frameworks To Shorten Your Development Time
- php time
- 本地时间(LocalTime)、系统时间(SystemTime)、格林威治时间(UTC-Time)、文件时间(FileTime)之间的转换
- Time to S5Time,S5Time to Time
- I took time for preliminary study of the lua and php, it's too difficlt to squeeze time for me
- Time to say goodbye
- no time to say
- Time to Change
- How to use time...
- Time to move
- time to say sth
- time to say goodbye
- to get time
- Time to start blogging
- three.js 源码注释(七十三)extras/geometries/TextGeometry.js
- 聊聊架构-模块化
- Codeforces Round #286 div.1 D 506D D. Mr. Kitayuta's Colorful Graph【并查集】
- Boa移植过程
- [Leetcode] 35 - Search Insert Position
- php time to systemtime
- dom4j创建xml文件
- 使用android-async-http-master框架异步获取数据
- 简单的iOS引导页
- leetcode MergeTwoSortedList
- 20150130
- t440p在windows2008下装蓝牙驱动
- SVN使用:Ubuntu下SVN的使用
- Matlab和C#的数据传递