How to get date and time from server

后端 未结 7 1898
感动是毒
感动是毒 2020-12-14 16:48

I want to retrieve date and time from server and according to it do some thing. For this I used following code:

$info = getdate();
$date = $info[\'mday\'];
$         


        
7条回答
  •  心在旅途
    2020-12-14 17:10

    You can use the "system( string $command[, int &$return_var] ) : string" function. For Windows system( "time" );, system( "time > output.txt" ); to put the response in the output.txt file. If you plan on deploying your website on someone else's server, then you may not want to hardcode the server time, as the server may move to an unknown timezone. Then it may be best to set the default time zone in the php.ini file. I use Hostinger and they allow you to configure that php.ini value.

提交回复
热议问题