Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help for PHP time() function

Status
Not open for further replies.

paispatin

Technical User
Oct 21, 2003
62
A1
Dear all,

As we know we could use time() function, but I have some problem with it :

this is my code :
Code:
<?

$linux_time=time();
$normal_date=gmdate("d-m-Y",$linux_time);
$normal_time=gmdate("h:i A",$linux_time);

echo "unix time = $linux_time";
echo "<p>normal date = $normal_date";
echo "<p>normal time = $normal_time";

?>

The Problem is :
How to determine the first time of this day (with linux time)?

Something like this, if I have log all visitors web and save it at mysql (I save the time() output), than how to make a script to filter only the visitor at this day only could be show?

Thank you in advance.
 
Have you looked at the mysql column type TIMESTAMP? The first column of that type automatically sets itself when a new record is entered. It also updates when the record is altered.
 
Thank for reply.
I try to make my problem simple, run that script at php server, the value is :


unix time = 1092634919
normal date = 16-08-2004
normal time = 05:41 AM


Well, at the unix time, how do I make it as 16-08-2004, 00:00 AM?

Thank you in advance.
 
Your solution lies in the following function:

You have the day, month, and year for the nromal date available, so feed it into the mktime function with hour=0, minute=0, and second=0:
Code:
$midnight = mktime(date("m"), date("d"),  date("Y"));\
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top