[thelist] Convert string to date

~kristina kristina at kfx-design.co.uk
Wed Jul 10 15:28:01 CDT 2002


Mia

//comments below....

on Wednesday, July 10, 2002, 11:48:09 AM, mia declared:

<:>
> If you're going to convert those into a date, you need to build a string
> to give to the function that makes a date from a string first.  I've given
> an example below.

> You can use strtotime() (http://www.php.net/strtotime) or mktime()
> (http://www.php.net/mktime) with time() to get the current time, or date.
> There's a list of acceptable date formats at
> http://www.gnu.org/manual/tar-1.12/html_chapter/tar_7.html you can check
> if your string isn't working.

> Have you looked up the function definitions at php.net to check what input
> (arguments) you should be using, and what you should be getting back from
> the function?  You can get information about any function by going to
> http://www.php.net/functionname.

> You'd want to check the format, but once I've got the my date into date
> format, I use date() to format it again and compare it to today.

> (Probably horribly inefficient) example:

> // get today's date, format it for comparison
> $today = date("j n Y", time())

> // get the data from the form usable, format it for comparison
> $expirydate = mktime(0,0,0, $deletemonth, $deleteday, $deleteyear);
> $expirydate = date("j n Y", $expirydate);

> // then use it like this
> if ($today == $expirydate) {
>         // This is from your example
>         // but note that you don't need '*' in a DELETE
>         $query = "DELETE FROM tableName WHERE expirydate=$expirydate";

>         // uncomment the line below to print your query to the
>         // screen for easier testing
>         //echo $query;

>         // whatever database calls you need to send the query
> }
<:>

Thanks for your reply, I think I may have forgotten to mention that
I'm a complete newbie at all of this php/mysql stuff..!!

Hence I didn't fully understand your reply, any chance you can give me
a 'simpleton's version...?

--
tia
~kristina

kristina at kfx-design.co.uk
http://kfx-design.co.uk/





More information about the thelist mailing list