0

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

3
Contributors
10
Replies
50
Views
4 Years
Discussion Span
Last Post by diafol
0

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?

0

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>)

Edited by diafol

0

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

0

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

0

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>";
?>

Edited by diafol: fixed formatting

0

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");
?>

Edited by UK-1991

0

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?

Edited by diafol

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.