Jump to content

Recommended Posts

Hi there, I have a login table which shows the login details, the login & logout time. but it does not show my pc time. it shows the time which is 1 hour ahead of my laptop. can anyone plz tell me how can I solve the problem?

here is the all code.

<?php 
session_start(); 
require_once("config.php");
if(!$_SESSION['username'])
{
header("Location: loginpage.php");
}
?>


<?php
  $query="select f_name from student_details where username='".$_SESSION['username']."'";
  $res=mysql_query($query);
  $data=mysql_fetch_object($res);
  

  
  ?>

<?php
		  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 );
}

		  /*$query="select * from student_details where username='".$_SESSION['username']."'";
		  $result=mysql_query($query);
		  $fetch=mysql_fetch_object($result);*/
		  
		$qry="select * from userlogin_info where user_id ='".$_SESSION['username']."'";
		  $res=mysql_query($qry);
		  
		  	$i=0;	  
		while($usrObj = mysql_fetch_object($res))
			{
			if($i%2!=0)
			{
			$trcolor = "#666666";
			}
			else
			{
			$trcolor = "#333333";
			}
			$login_time="";
			$logout_time="";
			$login_time=$usrObj->login_time;
			$logout_time=$usrObj->logout_time;

			$ex_login_time="";
			$ex_logout_time="";
			$ex_login_time=substr("$login_time",-8,;
			$ex_logout_time=substr("$logout_time",-8,;




?>


<?php if( $diff=@get_time_difference($ex_login_time, $ex_logout_time) )
{
  
      echo  sprintf( '%02d:%02d:%02d', $diff['hours'], $diff['minutes'],$diff['seconds'] );
}
else
{

}
?>


<?php
		  $i++;
}
?>

these all codes are in the same file.

 

thanks

 

Link to comment
https://forums.phpfreaks.com/topic/160003-timezone-set-up/
Share on other sites

What OS does it run? Is it your own dedicated server? If it is a shared server then you wont have the permission to do this. Look at redarrows post on setting the timezone within the script instead. You would put this within a gloab include file.

Link to comment
https://forums.phpfreaks.com/topic/160003-timezone-set-up/#findComment-844032
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.