Board index   FAQ   Search  
Register  Login
Board index PHP PHP Scripts

To select time of a day before

Links for php scripts

Moderators: macek, egami, gesf

To select time of a day before

Postby sansoft » Mon May 31, 2004 11:34 pm

Hi all,

i have got a table taskdatetime with fields entertime and outtime.this table is accessed by users who login and logout.the users logout after 9 hrs of work.
Now some users forget that they have to logout.So when they login the next day a message shud pop up that they have not registered the "logout THE DAY BEFORE"........plz tell me how will i access the record the day before.....................

i know tht subtracting now()-86400 will give me the day before ...but i still dont know how to access.....

Also my version of mysql< 4.1.1 so no modern functions plz

i can use only unix_timestamp function...nothing else...........


plz help......

Sansoft
sansoft
New php-forum User
New php-forum User
 
Posts: 44
Joined: Fri May 07, 2004 2:16 am
Location: India

Re: To select time of a day before

Postby WiZARD » Tue Jun 01, 2004 1:22 am

i try help to you.
Algorythm not hevy.....

1) Get the current date (user loged in)
2) add this date into DB like lastvisit
user get out from site....
if user want to site again
3) check different from cuttent date and lastvisit

if you using that algorythm you may use any type of date
it's simple math
User avatar
WiZARD
Moderator
Moderator
 
Posts: 1257
Joined: Thu Jun 20, 2002 10:14 pm
Location: Ukraine, Crimea, Simferopol

Postby Redcircle » Sun Jun 06, 2004 11:14 am

If you aren't restricted from doing it in mysql you can use PHP functions.

Code: Select all
<?php
$tomorrow  = mktime(0, 0, 0, date("m")  , date("d")+1, date("Y"));
$lastmonth = mktime(0, 0, 0, date("m")-1, date("d"),  date("Y"));
$nextyear  = mktime(0, 0, 0, date("m"),  date("d"),  date("Y")+1);
?>


same goes for the hours etc
User avatar
Redcircle
Moderator
Moderator
 
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA

problem solved

Postby sansoft » Tue Jun 08, 2004 2:05 am

Hi all,

thank you very much....the problem is solved by using the following code..................

Code: Select all


$tomorrow  = mktime(0, 0, 0, date("m")  , date("d")-1, date("Y"));
$tomorrow = getdate($tomorrow);


if($tomorrow["mon"]<10)
{
$tomorrow["mon"]="0".$tomorrow["mon"];
}

if($tomorrow["mday"]<10)
{
$tomorrow["mday"]="0".$tomorrow["mday"];
}



$yesterday  = $tomorrow["year"] . "-" .$tomorrow["mon"] . "-". $tomorrow["mday"]." 00:00:00";

$sqllogouttime="select * from taskdatetime where date_format(outtime,'%Y-%c-%d')=date_format('$yesterday','%Y-%c-%d') and user_id='$sesuserid'";




$result=mysql_query($sqllogouttime,$conn);

$numrowsoflogout=mysql_num_rows($result);

if($numrowsoflogout==0  )
{


$sqlinsflag="insert into taskdatetime(user_id,entertime,outtime,flag)values('$sesuserid','$yesterday','$yesterday','absent')";
$resultinsflag=mysql_query($sqlinsflag,$conn);

header("location:message.php");
}














sansoft
New php-forum User
New php-forum User
 
Posts: 44
Joined: Fri May 07, 2004 2:16 am
Location: India


Return to PHP Scripts

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron