Jump to content

shareen

New Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

shareen's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi, i have used the link and its not giving me any value. Any clues why? This is the date from the database 28-04-06 16.52.51 Then i am trying to take away the current time. Time now is 16:53:34 [code]$array = explode(" ",$starttime); $array2 = explode("-",$array[0]); $array3 = explode(".",$array[1]); echo $starttime . "<br>"; $seconds_dif = mktime($array2[0],$array2[1],$array3[2],$array3[0],$array3[1],$array3[2]) - mktime(date("d"),date("m"),date("y"),date("G"),date("i"),date("s")); echo "Seconds:" . floor($seconds_diff);[/code] Please help, this is getting very awkward.
  2. Hi, thanks for the link. Almost there i think. The value i want to compare it to is the database value. It gives me a really really high number, that is no where near the true value. Any ideas? [code]$seconds_dif = mktime($starttime) - mktime(date("d"),date("m"),date("y"),date("G"),date("i"),date("s")); echo $seconds_dif;[/code] 1146193195 This is the answer This is no where near the ammount. I insert it and press it refresh and the difference should be a few seconds. I have no idea why.
  3. Hi, sorry my fault. The problem was always printing out the seconds. I would just like to get the number of seconds between the two values.
  4. Hi the problem is printing out the number of seconds. I would just like to do a simple difference find between the two values.
  5. Hi, yes thats the error message returned. Do you know why its returning this and not the difference in seconds please?
  6. Hi, I am trying to calculate the number of seconds difference between two dates. The problem is this function keeps returing an error and i am definitley returning two time and dates with seconds included. Does someone know where i am going wrong? The dates and times definitley have seconds. This is the function [code]function get_time_difference( $start, $end ) {     $uts['start']      =    strtotime( $start );     $uts['end']        =    strtotime( $end );     if( $uts['start']!==-1 && $uts['end']!==-1 )     {         if( $uts['end'] >= $uts['start'] )         {             $diff    =    $uts['end'] - $uts['start'];             if( $days=intval((floor($diff/86400))) )                 $diff = $diff % 86400;             if( $hours=intval((floor($diff/3600))) )                 $diff = $diff % 3600;             if( $minutes=intval((floor($diff/60))) )                 $diff = $diff % 60;             $diff    =    intval( $diff );                         return( array('days'=>$days, 'hours'=>$hours, 'minutes'=>$minutes, 'seconds'=>$diff) );         }         else         {             trigger_error( "Ending date/time is earlier than the start date/time", E_USER_WARNING );         }     }     else     {         trigger_error( "Invalid date/time data detected", E_USER_WARNING );     }     return( false ); }[/code] This is the piece of code that returns the error or the difference. [code]if( $diff=@get_time_difference($starttime, $endtime) ) {   echo "Hours: " .        sprintf( '%02d:%02d', $diff['hours'], $diff['minutes'] ); } else {   echo "Hours: Error"; }[/code]
  7. Hi, i am new here. I am having an issue with PHP. Its giving me a really annoying error and i can't figure out why. The error: [b]Parse error: parse error, unexpected $ in /home/stud/1/c0261087/public_html/blog/process2.php on line 99[/b] Can someone see something i can't? [code]<?php include "./db_lib.inc"; $link_id = db_connect(); $postId = $_Post['id'];              $sqlquery = "SELECT date FROM $locking_tablename where [id] = $postId ";         $result = mysql_query($sqlquery);          while($row = @mysql_fetch_array($result)) { $starttime = $row['date']; $endtime = date("d-m-y G.i"); } if ($diff = @get_time_difference($starttime,$endtime)) { echo "Minutes" . sprintf( '%02d',$diff['minutes'] ); } if ($_POST['text'] == '' || $_POST['author'] == '' ) { echo "Please fill out all elements."; echo "<a href=\"comment.php?Name=$DisplayName\">Back</a>"; die(); {          $text = $_POST['text'];     $author = $_POST['author'];          $title = $_POST['title'];     $date = date("d-m-y G.i");                                $query = "INSERT INTO $locking_tablename (`title` , `author` , `date` , `entry`)         VALUES ('$title', '$author', '$date', '$text')";         $result = mysql_query($query);         if (!$result) {               error_message(sql_error());             } else {             echo "Post successful!<br />";             echo "Your Comment ". $text . ". <br />";             echo "Author:" . $author . ".<br />";             echo "To log out <a href='logout.php'>click here</a><br />";             echo "To Post a new comment <a href='comment.php'>click here</a>";          } } function get_time_difference( $start, $end ) {     $uts['start']      =    strtotime( $start );     $uts['end']        =    strtotime( $end );     if( $uts['start']!==-1 && $uts['end']!==-1 )     {         if( $uts['end'] >= $uts['start'] )         {             $diff    =    $uts['end'] - $uts['start'];             if( $days=intval((floor($diff/86400))) )                 $diff = $diff % 86400;             if( $hours=intval((floor($diff/3600))) )                 $diff = $diff % 3600;             if( $minutes=intval((floor($diff/60))) )                 $diff = $diff % 60;             $diff    =    intval( $diff );                         return( array('days'=>$days, 'hours'=>$hours, 'minutes'=>$minutes, 'seconds'=>$diff) );         }         else         {             trigger_error( "Ending date/time is earlier than the start date/time", E_USER_WARNING );         }     }     else     {         trigger_error( "Invalid date/time data detected", E_USER_WARNING );     }     return( false ); ?>[/code]
×
×
  • 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.