Jump to content

timezone set up


bal bal

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.