douhan8430 2015-09-16 06:38
浏览 351
已采纳

使用PHP和LDAP设置accountexpires日期

I'm having trouble setting the 'accountexpires' and wondered if anyone knows a way around it, I believe it's because I have a 18 digit number. I have a form where someone sets a date, I need to set the account to expire then, if I provide the number as a hardcoded string it works, but I cannot convert the finished calculation to a string. Anyone know any way around this? thanks.

<?php
$currentTimeUnix = 1442383989; //this will vary depending on user's input
$secondsBetween1601and1970 = 11644473600;
$timesAdded = $currentTimeUnix + $secondsBetween1601and1970;// comes to 13086857589
$nanoseconds = $timesAdded * 10000000; //comes to 130868575890000000
echo $nanoseconds; //displays 1.3086857589E+017
echo (string)$nanoseconds; //displays 1.3086857589E+017
echo strval($nanoseconds); //displays 1.3086857589E+017
?>
  • 写回答

1条回答 默认 最新

  • doumei4964 2015-09-16 06:54
    关注

    PHP is kind of bad with large numbers but sprintf can help. try:

    echo sprintf( '%018.0f', $nanoseconds );
    -> 130868575890000000
    

    Alternatively you change the "precision" setting where precision is described:

    precision integer

    The number of significant digits displayed in floating point numbers.
    
    ini_set("precision",20);
    echo $nanoseconds;
    -> 130868575890000000
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥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