Hello everybody,

I need help to sort out the following issue:

I want to calculate the time between a comment form is loaded (displayed to a user) and when values are being inserted in database. I've used following code in my module.

function mymodule_comment($a1, $op) {
   static $comment_stamp=0;
   if($comment_stamp == 0) $comment_stamp = time();
   switch($op) {
      case "form":
		   $a1['comment_stamp'] = array(
		   			'#type' => 'hidden',
					'#value' =>  $comment_stamp,
		   			);
                  return $a1;
                  break;
     case "insert":
		   $comment_stamp = $a1['comment_stamp'];
		   
		   $time_now = time();
		   
                  print("Time now = ".$time_now." difference = ".($time_now-$comment_stamp));
		   break;
   }
}

But surprisingly drupal is resetting the value of static variable. For "insert" case the values of variables $comment_stamp and $time_now are same..

As far as i know static variables retain their values even when the function exits. i dont know what is happening here, may be some internal drupal processing is resetting the value for variable $comment_stamp.

Please help. All help will be greatly appreciated.

Many thanks in advance.