Jump to content

[Solved] comparing times


BillyBoB

Recommended Posts

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.
Link to comment
Share on other sites

this should of worked sorry no luck.

[code]
<?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;

?>
[/code]
Link to comment
Share on other sites

[quote author=BillyBoB link=topic=104559.msg417180#msg417180 date=1155781902]
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
[/quote]

It should work if all three variables in my example are timestamps.
Link to comment
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.