Hello All bellow is the code for time in which is not showing up when i login as admin.

Php Code:

<?php $query = "select * from presence where uid=".$uid." and date='".$date."'";
$recordset = mysql_query($query);
while($record = mysql_fetch_array($recordset))
{$count = 1;
//echo "<td>Your Time In :==: ",$record["timein"],"</td></tr><br></table>";
echo "<center><table><tr><td>Your Time In : ",$record["timein"],"</td></tr></table></center>";
$lasttimeout = $record["timeout"];
}
echo "<center><table><tr><td>Your Time Out : ",$lasttimeout,"</td></tr></table></center>";
?>

When i login as admin the time in is not showing up. But when i login as a user it shows time in. Secondly time zone is also difference. Like when i click on time out button that is quite different according to my system time I hope I made every thing clear.

If this code i wrong so can you also advise me any other code for time in only ?

Regards
Usman

Image is Atteched As Well f32c56402f5d760122ae000fed01acc8

yes but i did'nt got the solution that's why i desided to ask you again. Could you please guide me where i have to put the script? and why time in is not showing up?

Member Avatar for diafol

yes but i did'nt got the solution that's why i desided to ask you again

In that case, stay on the same thread.

Could you please guide me where i have to put the script

Put it at the top of each page that deals with time in and time out. Store time as timestamp.

echo "<center><table><tr><td>Your Time In : ",$record["timein"],"</td></tr></table></center>";
echo "<center><table><tr><td>Your Time Out : ",$lasttimeout,"</td></tr></table></center>";

The concatenator is a '.' not a ','

echo "<center><table><tr><td>Your Time In : ".$record["timein"]."</td></tr></table></center>";
echo "<center><table><tr><td>Your Time Out : ".$lasttimeout."</td></tr></table></center>";

Or even:

echo "<center><table><tr><td>Your Time In : {$record["timein"]}</td></tr></table></center>";
echo "<center><table><tr><td>Your Time Out : $lasttimeout</td></tr></table></center>";

BTW, don't use <center> - use styling (CSS file or <style> or even inline styling: <tag style="..."></tag>)

stil facing the same problem. Still showing up different time.

Member Avatar for Zagga

As diafol mentioned, you can get and set the default timezone to make sure you and the server are working on the same timezone.

See the PHP Manual

Yes I viewed it but i am not understanding where tu put that code and how. Below is the code for time in and there is also a problem that when i login in not gives the exact time in.

Code

<?php $query = "select * from presence where uid=".$uid." and date='".$date."'";
$recordset = mysql_query($query);
while($record = mysql_fetch_array($recordset))
`{$count = 1};`
//echo "<td>Your Time In :==: ",$record["timein"],"</td></tr><br></table>";
echo "<center><table><tr><td>Your Time In : ",$record["timein"],"</td></tr></table></center>";
$lasttimeout = $record["timeout"];
`}`
echo "<center><table><tr><td>Your Time Out : ",$lasttimeout,"</td></tr></table></center>";
?>
Member Avatar for diafol

Put the timezone code at the top of each page that uses any time variables.

This is how i putted the code but still not working and when i log in it not give time in as well.

<?php
date_default_timezone_set('America/Los_Angeles');

$script_tz = date_default_timezone_get();

if(strcmp($script_tz, ini_get('date.timezone'))) {
echo '(Script timezone differs from ini-set timezone.)';
} 
else 
{
    echo 'Script timezone and ini-set timezone match.';
}
?>

I putted the above code at the top of my page Like This

<?php
date_default_timezone_set('America/Los_Angeles');

$script_tz = date_default_timezone_get();

if (strcmp($script_tz, ini_get('date.timezone'))){
    echo 'Script timezone differs from ini-set timezone.';
} else {
    echo 'Script timezone and ini-set timezone match.';
}
?>

<?php
    include_once("include/uchecksession.php");
    @$uid = @$_SESSION["uid"];          
    include_once("include/config.php");
?>
Member Avatar for diafol

You don't mention what the outcome is. I would imagine that the ini TZ will be different to the newly set TZ. The ini TZ is hard-coded into the file, so you won't change that. That's why you have to set the timezone on each page where you are dealing with TZ times. Timestamps are universal - that is - they're a snapshot of an instant in time everywhere in the world. It's the TZ setting that gives them a regional context. So for example,

1370695847 = Saturday June 08, 2013 12:50:47 (GMT) and = Saturday June 08, 2013 05:50:47 (America/Los Angeles). See my hobby page for a calculator ( http://www.diafol.org/datetime.php )

Sorry, if you were already aware of that. COuld you provide more info wrt the error? What bit of code is failing to work as expected?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.