PHP Time()函数在C ++中 [英] Php time() function in c++

查看:78
本文介绍了PHP Time()函数在C ++中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,我只是想通过调用time()来获得一个等于在php中生成的值.

这是由php生成的:1353963208650

而这个由c ++编写:1353963158

它们相等,但是以某种方式,c ++值仅为4个字节.最后4个字节为空,但我需要一个等于100%的值.我的代码atm:

Hello I just tried to get a value which equals to the one which is generated in php by calling time().

This one was generated by php: 1353963208650

And this one by c++ : 1353963158

They equal but somehow the c++ value is just 4 bytes. The last 4 bytes are nulled,but I need a value which equals 100%. My Code atm:

time_t seconds = time(NULL);
printf("PHP-Time: %ld\n",seconds);

推荐答案

您是如何得到结果的?
我的测试:
(输出)
How did you get your results?
My test:
(output)
>
1353965820(C ++)
1353965860(PHP)

1353965820 (C++)
1353965860 (PHP)


(当然,它们是有所不同的,因为它们是在不同的时间执行的)

(程序)


(of course they differ a bit, because were executed at different times)

(programs)

#include <iostream>
#include <ctime>
using namespace std;
int main()
{
  cout << time(NULL) << endl;
  return 0;
}


<?php 
echo time();
 ?>


这篇关于PHP Time()函数在C ++中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆