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
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型