Jump to content

php get current time


Issam

Recommended Posts

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.