dqwh1119 2011-11-25 05:59
浏览 361
已采纳

如何正确显示时间戳

The api we use generates a set of time stamps for us - We have tried to turn these into the proper values but no matter what we try it is just coming back as around 24-04-1937, 10:53:52 which would be good .. except it was only generated around 5 days ago

The time stamps we have to work off are in the format : 1.321818372E+12

The API developer had posted this section to help someone else with the same issue but for some reason it doesnt seem to be working for us we have tried to change a few variables on the test server but the date just keeps going further back in time

$achname = $achievements[0]['name'];
$achtime = substr($achievements[0]['timestamp'], 0, -3);
$format = '%d-%m-%Y, %H:%M:%S';
$strf = strftime($format, $achtime);

Im just not too sure as to what is wrong with it

Thanks

  • 写回答

1条回答 默认 最新

  • douzhan1238 2011-11-25 06:04
    关注

    What you're looking at is a JS timestamp, it's in milliseconds. Just divide it by 1000 to get the UNIX timestamp.

    $timestamp = $achievements[0]['timestamp'] / 1000;
    echo date('d-m-Y', $timestamp);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog