Jump to content

php get current time


Issam

Recommended Posts

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

Link to comment
Share on other sites

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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.