Jump to content

Recommended Posts

How would it work though because time stamps have this kinda format:

 

2008-07-26 16:05:05 not straight forward integer format with all the - and : symbols..

 

 

Also, if you wanted to grab the minutes of it do you just do:

 

 

$hours = $z / 60 / 60 / 60;  ?

no, time stamps are integers of the date in seconds since the unix epoch.  That's just a format.  What you want to do is use strtotime() to get the timestamp from your formatted times and then use some basic math.  Subtract one from the other, and you got the difference in seconds.  Divide that by 60, and you have the difference in minutes, etc...

Didn't quite seem to work for me !  :-\

 

I have:

 

<?php
$Date = 2008-07-26 14:50:58;
$Now = 2008-07-26 16:55:58;

$Date = strtotime($Date);
$Date2 = strtotime($Now); 

$Difference = $Date - $Date2;
$Difference = $Difference / 60;

Echo $Difference.' minutes';
?>

 

Response

-338079.873333 minutes

 

It should be in the negative but not by -338,079 minutes.

Yeah i thought it might have been that but when i did this to get the two times :

 

 

<?php
$Get = mysql_query("SELECT Date FROM table WHERE ID='$ID'")
Or die(mysql_error());
$row = mysql_fetch_assoc($Get);
$Date = $row['Date'];
$Now = date("Y-m-d H:i:s",time());
?>

 

I still got same answer.

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.