Re: Re: calculating datetime

From: Date: Sun, 31 Aug 2003 16:04:43 +0000
Subject: Re: Re: calculating datetime
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-161300@lists.php.net to get a copy of this message
Hi, Thanks for replying. Am a bit confused even after your example as to how to enter this into the datetime field in mysql so that i can compare it to the present datetime heres the code i made based on what you said: <?php $day=2; $hour=2; $seconds=05; $theDay=24*60*60; $theHour=60*60; //$theSec=$seconds; $FinalDay=$day*$theDay; $FinalHour=$hour*theHour; $offset=$FinalDay + $FinalHour + $seconds; $FinalTime=time() + $offset; print time(); echo "<br><br>"; print $FinalTime; echo "<br><br>"; $Result=mktime($FinalTime); echo $Result;//gives a warning or error ?> Its giving me a number based on the above that is correctly higher than time() but how do i enter that into mysql for a comparision? eg: my table structure in mysql is so: present_day datetime expire_day datetime filename varchar(50) (my logic) if ($present_day - $expire_day <= 0) {echo "link expired";} //else //give file Kindly reply, -Ryan > Hi, > > offset = 1day + 1hour + 10 secs = 24 * 60 * 60 + 60 * 60 + 10 (seconds) > time() + offset = the time you need > or > $now = explode('.', date("d.m.Y.H.i.s", time()); > $now is array ( 0 => the day, 1 => the month. aso) > add to the elements of the array the values you need > then turn it back into a timestamp with mktime() > > Cheers, > Catalin > > "Ryan A" <r@no7.biz> wrote in message > news:001a01c36fc1$ec7e7e70$f081aa51@l2zcaxu7emppqh... > > Hi, > > I have a datetime field in my table, i want to enter a datetime 1 day,1 > hour > > and 10 mins into the future from today/the present, how do i calculate > that? > > > > This is for the expiring links/members part of a script i am trying to > > create. > > > > > > I have looked around the archive and google but maybe i didnt find the > > correct thread. > > Google turned up these revelient results but are not too much help: > > > http://forums.devshed.com/showthread.php?threadid=4238&kw=get+current+date+and+time+of+server > > > > useing the date function > > > > http://www.phpbuilder.com/mail/php-general/2002062/1026.php (rasmus) > > > > now() > > > > http://www.phpbuilder.com/mail/php-general/2002062/1033.php (john) > > > > This was very helpful but it brings up the other question of is the local > > php time on the server the same as the one on mysql? Logically it should > be > > but...... > > > http://www.google.com/url?sa=U&start=3&q=http://www.phpbuilder.com/manual/ref.datetime.php&e=7391 > > > > > > > > Thanks in advance, > > -Ryan > > > > > > We will slaughter you all! - The Iraqi (Dis)information ministers site > > http://MrSahaf.com > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > >

« previous php.general (#161300) next »