Jump to content


Photo

[Solved] comparing times


  • Please log in to reply
11 replies to this topic

#1 BillyBoB

BillyBoB
  • Members
  • PipPipPip
  • Advanced Member
  • 630 posts

Posted 17 August 2006 - 12:34 AM

i have a timestamp in a db called timein

i want to have it show the how long its been since the last login.
i want it to take time out of db and compare it with the date() function of php and display the dtime between them.

Can u help me ? (there happy)

#2 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 17 August 2006 - 12:39 AM

Cool.

#3 Nothadoth

Nothadoth
  • Members
  • PipPipPip
  • Advanced Member
  • 119 posts

Posted 17 August 2006 - 12:41 AM

I think that was your que to help him. Not say cool

Sorry billy, im a newb i cant help. Just thought thorpe's post was dumb

#4 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 17 August 2006 - 12:44 AM

Statements are not questions, its a pretty simple concept. You'll find a link in my signiture if you need clarification.

#5 BillyBoB

BillyBoB
  • Members
  • PipPipPip
  • Advanced Member
  • 630 posts

Posted 17 August 2006 - 01:09 AM

dude stop being an ass just anwser my question

#6 Jeremysr

Jeremysr
  • Members
  • PipPipPip
  • Advanced Member
  • 199 posts
  • LocationSaskatchewan, Canada

Posted 17 August 2006 - 01:15 AM

Just subtract the times.

$time_inbetween = $current_time - $intime;

Where $current_time is the current timestamp and $intime is the timestamp in the database. $timeinbetween should be a timestamp (the number of seconds between the two other timestamps)

So use date() with $time_inbetween to get the number of hours/minutes/seconds/days/weeks or whatever you want.

#7 BillyBoB

BillyBoB
  • Members
  • PipPipPip
  • Advanced Member
  • 630 posts

Posted 17 August 2006 - 02:31 AM

nope that wont work ... it will not work because what if the timein is jan. (01) and the current time is nov. (11) that would give me -10

#8 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 17 August 2006 - 02:54 AM

this should of worked sorry no luck.

<?php

$old_date=date("01-02-09");

$old_result=strtotime($old_date);

$date_now=date("d-m-y");

$date_now_result=strtotime($date_now);

$results=$date_now_result-$old_result;

$total_result=date("d-m-y",$results);

echo $total_result;

?>

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#9 Jeremysr

Jeremysr
  • Members
  • PipPipPip
  • Advanced Member
  • 199 posts
  • LocationSaskatchewan, Canada

Posted 17 August 2006 - 03:02 AM

nope that wont work ... it will not work because what if the timein is jan. (01) and the current time is nov. (11) that would give me -10


It should work if all three variables in my example are timestamps.

#10 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 17 August 2006 - 03:44 AM

dude stop being an ass just anwser my question


Read your post again. There is no question!

#11 BillyBoB

BillyBoB
  • Members
  • PipPipPip
  • Advanced Member
  • 630 posts

Posted 17 August 2006 - 03:48 AM

Can u help me ? (there happy)


whats that i can see one how bout u

#12 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 17 August 2006 - 03:51 AM

Oh... well, no then.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users