cmd 可以通过 net time  192.168.0.2 /set /y 。通过同步时间。
那php怎样可以获取 192.268.0.2 这台机器上面的时间戳? 求高人

解决方案 »

  1.   

    <?php
    function net_time() {
        // set user and password
        shell_exec("net use \\\\192.168.0.2 \"password#\" /user:\"username\"");    $output = array();
        $host = '192.168.0.2';
        $cmd = sprintf('net time \\\\%s', $host );    $output = shell_exec( $cmd );
        $array = explode("\n\n", $output);
        $array = explode(" ", $array[0]);    $array1 = explode("/", $array[2]);
        $array2 = explode(":", $array[3]);    date_default_timezone_set("Etc/GMT-8");
        return mktime($array2[0], $array2[1], $array2[2], $array1[1], $array1[2], $array1[0]);
    }
    ?>
    完美解决!