Re: Date Subtraction

From: Date: Wed, 07 Nov 2001 21:18:38 +0000
Subject: Re: Date Subtraction
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-73799@lists.php.net to get a copy of this message
Ahh I see.. yeah you don't need MySQL. MySQL is only for database operations and it doesnt even sound like you're running a database. Ok here goes.. let me see if I can figure this out. <? $today = time(); $yourdate = strtotime("May 25, 2002 2:00pm"); $diff = $yourdate - $today; ?> $diff will return the amount of seconds from right now until the specified date. You can format it anyway you would like.. with a little math you can figure out how many minutes until that date.. how many hours, days, months, years, etc etc Rick > From: Dan Tappin <dan@tappin.ca> > Date: Wed, 07 Nov 2001 13:50:25 -0700 > To: Richard Baskett <rick@baskettcase.com> > Subject: Re: [PHP] Date Subtraction > >> With MySQL you can do a select query and use UNIX_TIMESTAMP which will >> return a timestamp of the date within the MySQL table. If you call time() >> or time()+60*5 would equal the current time + 5 minutes, once you get the >> "future" date/time correct then just subtract it from the MySQL time, or >> vice versa whichever fits what you are doing. >> >> If this didnt answer your question fully, do not hesitate to email me. >> Thanks! > > You lost me. I have MySQL running but this is not where my date is coming > from. I got the impression that it is just easier to do via MySQL. > > I need the difference between now and 2:00 pm May 25, 2002. Can you help me > with the query statement? > > Thanks, > > Dan >

« previous php.general (#73799) next »