RE: time function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Since PHP only runs on the server it only has direct access to the server
time.
The big integer number that you retrieve with the time function is the
number of seconds since unix epoche
http://www.php.net/manual/en/function.time.php which was Jan 1 1970 00:00:00
GMT.

Use the date function to convert that large number to something you can
read. http://www.php.net/manual/en/function.date.php.  A convenient way of
doing this is;

$timestampstring = date("Y-m-d H:i:s",time()); or
$timestampstring = date("Y-m-d H:i:s");

Note that you really don't need to code the current "time" function since
the date function will default to the current time in the absense of a
second variable being passed to the date function, I show it here to make it
clear that the "big number" is a unix binary representation of the current
time, and you can also use the date function to convert these large numbers
to a format that you read, even those large numbers that are stored in a
data base in the "time" binary form.

To get the time on the client machine you will need to use Javascript to
place the visitors current time in a hidden variable in a form and submit
that along with any other data to your server.  Google can help you find
lots of scripts to do this, or you can just go to http://www.hotscripts.com
and find one there.

Hope this helps,

Warren Vail

-----Original Message-----
From: Nishantha Pradeep [mailto:nishantha@xxxxxxx] 
Sent: Thursday, October 18, 2007 10:39 PM
To: php-windows@xxxxxxxxxxxxx
Subject:  time function

I want to insert the loging time for a system and i used php "time()"
function but it returns some big number.What is that big number and how I
retrieve the current server or client time using php.

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux