Jump to content

Recommended Posts

$timestamp_plushour = time() + 3600;
$formatted_date = date('H:i:s', $timestamp_plushour);
echo $formatted_date;

 

there are a zillion ways to skin the cat when it comes to dates and times; this is but one of them.

 

EDIT:  CV's brief post has beaten me to the punch - thine fingers are brisk, CV.

Link to comment
https://forums.phpfreaks.com/topic/124860-time/#findComment-645054
Share on other sites

Thanks, so I have this in my database:

 

time_visited = 21:00:00

 

How would I compare the current time using

        $time = time() + 3600;
        $expire_time = date('H:i:s', $time);

 

to time_visited?

 

Thanks

 

that only works for UNIX timestamps, which time() generates.  if your time is in the database in TIME format, you can simply use:

 

DATE_ADD(time_visited, INTERVAL 1 HOUR)

 

in MySQL itself.

Link to comment
https://forums.phpfreaks.com/topic/124860-time/#findComment-645070
Share on other sites

Doesn't work.. Hmmm....

 


        $time = time() + 3600;
        $expire_time = date('H:i:s', $time);
        $sql = "SELECT username FROM login WHERE DATE_ADD(last_visit_time, INTERVAL 1 HOUR) < $expire_time" or die(mysql_error
            ());
$result = db_query($sql);
        $users_online = array();
        while ($row = db_fetch_array($result)) {
        	echo $row['username'];
}

 

Thanks

 

 

Link to comment
https://forums.phpfreaks.com/topic/124860-time/#findComment-645083
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.