bal bal Posted May 28, 2009 Share Posted May 28, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/160003-timezone-set-up/ Share on other sites More sharing options...
JonnoTheDev Posted May 28, 2009 Share Posted May 28, 2009 Change the time on your webserver Quote Link to comment https://forums.phpfreaks.com/topic/160003-timezone-set-up/#findComment-844010 Share on other sites More sharing options...
redarrow Posted May 28, 2009 Share Posted May 28, 2009 http://uk3.php.net/manual/en/timezones.europe.php# <? echo "Original Time: ". date("h:i:s")."\n"; putenv("TZ=US/Eastern"); echo "New Time: ". date("h:i:s")."\n"; ?> http://www.modwest.com/help/kb5-258.html Quote Link to comment https://forums.phpfreaks.com/topic/160003-timezone-set-up/#findComment-844011 Share on other sites More sharing options...
bal bal Posted May 28, 2009 Author Share Posted May 28, 2009 thanks for the reply. I am new in this php world. can anyone please tell me exactly where I need to put the timezone code in my code? I am now in UK. thanks once again. Quote Link to comment https://forums.phpfreaks.com/topic/160003-timezone-set-up/#findComment-844022 Share on other sites More sharing options...
bal bal Posted May 28, 2009 Author Share Posted May 28, 2009 Change the time on your webserver how can I change my webserver time? Quote Link to comment https://forums.phpfreaks.com/topic/160003-timezone-set-up/#findComment-844024 Share on other sites More sharing options...
JonnoTheDev Posted May 28, 2009 Share Posted May 28, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/160003-timezone-set-up/#findComment-844032 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.