64,641
社区成员
发帖
与我相关
我的任务
分享
function do1(){
var t=$("#longval").val();
var d= new Date();
d.setTime(t);
var s = d.getFullYear() + "-" + d.getMonth() + "-" + d.getDay() + " " + d.getHours() + ":" + d.getMinutes()+":" + d.getSeconds() ;
$("#dateval").val(s);
}
#include<iostream.h>
#include<time.h>
void main()
{
tm * pTm;
//_getsystime(pTm);
long tmp = 1;
pTm = localtime(&tmp);//这里的long是UTC时间,也就是从1970年1月1日8时0分0秒开始偏移的秒数.tmp=1就表示1970/1/1 08:00:01
cout<<pTm->tm_year+1900<<"/";//+1900可以参考下面贴出的tm的声明
cout<<pTm->tm_mon+1<<"/";//+1也是参考tm的声明
cout<<pTm->tm_mday<<" ";
cout<<pTm->tm_hour<<":";
cout<<pTm->tm_min<<":";
cout<<pTm->tm_sec<<endl;
}
下面是time.h中tm和localtime的声明:
struct tm {
int tm_sec; /* seconds after the minute - [0,59] */
int tm_min; /* minutes after the hour - [0,59] */
int tm_hour; /* hours since midnight - [0,23] */
int tm_mday; /* day of the month - [1,31] */
int tm_mon; /* months since January - [0,11] */
int tm_year; /* years since 1900 */
int tm_wday; /* days since Sunday - [0,6] */
int tm_yday; /* days since January 1 - [0,365] */
int tm_isdst; /* daylight savings time flag */
};
_CRTIMP struct tm * __cdecl localtime(const time_t *);