doujuncuo9339 2015-06-02 05:21
浏览 150
已采纳

如何使用PHP代码获取Windows系统启动时间

Is it possible to fetch the booting time from the windows system using php code? I am doing a project and the requirement is to calculate the time from the system boot time to log off time. As I am new for developing I have no idea of how to fetch the boot time using php and store in mysql. I knew we can find it manually by giving the systeminfo | find /i "Boot Time" in windows7 command prompt. But is it possible grammatically using php?. I have searched for the possibilities but I get only for Linux OS. Can anyone help me in this issue? I am from testing background and new for developing.I need help.

  • 写回答

1条回答 默认 最新

  • donglie7778 2015-06-02 05:34
    关注

    Just copy/paste this:

    <?php
    $info = exec('systeminfo | find /i "Boot Time"');
    echo $info;
    ?>
    

    If you need only date:

    <?php
    $info = exec('systeminfo | find /i "Boot Time"');
    echo trim(str_replace("System Boot Time:", "", $info));
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘