How to get date and time from server

后端 未结 7 1914
感动是毒
感动是毒 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:13

    You should set the timezone to the one of the timezones you want. let set the Indian timezone

    // set default timezone
    date_default_timezone_set('Asia/Kolkata');
    
    $info = getdate();
    $date = $info['mday'];
    $month = $info['mon'];
    $year = $info['year'];
    $hour = $info['hours'];
    $min = $info['minutes'];
    $sec = $info['seconds'];
    
    $current_date = "$date/$month/$year == $hour:$min:$sec";
    

提交回复
热议问题