Issam Posted November 2, 2014 Share Posted November 2, 2014 Hi; I would like to get the current timestamp but the question is that i want to get the real time which is the machine bios time that can't change by the server administrator and not the server time which can be modified to any value. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/292232-php-get-current-time/ Share on other sites More sharing options...
hansford Posted November 2, 2014 Share Posted November 2, 2014 Try - date_default_timezone_set() function. http://php.net/manual/en/function.date-default-timezone-set.php Quote Link to comment https://forums.phpfreaks.com/topic/292232-php-get-current-time/#findComment-1495568 Share on other sites More sharing options...
Issam Posted November 2, 2014 Author Share Posted November 2, 2014 (edited) Hi hansford; Does the function time() is independent no matter what timezone the server is using and no matter which time the server is running on right ? Thanks Edited November 2, 2014 by Issam Quote Link to comment https://forums.phpfreaks.com/topic/292232-php-get-current-time/#findComment-1495574 Share on other sites More sharing options...
cyberRobot Posted November 3, 2014 Share Posted November 3, 2014 Hi hansford; Does the function time() is independent no matter what timezone the server is using and no matter which time the server is running on right ? Thanks I would imagine that all the date-related functions in PHP functions will be dependent of the time zone set on the server. The time() function, for example, provides different output based on the time zone. <?php print '<div>' . date('H:i:s', time()) . '</div>'; date_default_timezone_set('Africa/Abidjan'); print '<div>' . date('H:i:s', time()) . '</div>'; date_default_timezone_set('Europe/Helsinki'); print '<div>' . date('H:i:s', time()) . '</div>'; ?> If you are trying to get the time from the user's machine, you could look into using a client-side language like JavaScript. Quote Link to comment https://forums.phpfreaks.com/topic/292232-php-get-current-time/#findComment-1495600 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.