On Tue, 18 Sep 2001, * R&zE: wrote:

> > and get DD-MM-YYYY, but with well formed YYYY-MM-DD it doesn't match!. Is
> > this a bug?.
> It would help if you send the code you're using, 'cause we can't see
> what you're doing now. FAFAIK it should just be possible. See the

Sure:

--- start ---

$datenews = urldecode($datenews); // just in case, but it's the same
                                  // without this line and the one below.
$datenews = trim($datenews);

if (!ereg("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})", $datenews, $regs)) {
    echo "Duh! that is not a date, u kiddie: $datenews.";
    exit;
}
else echo "Cool! it is a date. Continue the proggie.";

--- end ---

where $datenews is passed as a get variable, which is obtained with this:

--- start ---

// the $regs array comes from the ereg expression above (the one which
// doesn't work as expected).

$timestamp = mktime(0,0,0,$regs[2],$regs[3],$regs[1]);
$yesterday = $timestamp - 86400; // one day before... that's yesterday :)
$yesternews = date("Y-m-d",$yesterday);

// here I pass the new datenews to myself:

print "<a href=\"$PHP_SELF?datenews=".urlencode($yesternews)."\">Older news</a>\n";

--- end ---

This sometimes work, but sometimes it doesn't randomly, even with the same
date both times, and the worst thing is that the "failure notice" prints
the right date in the right format. Now I went back to php-4.0.6
(apache-1.3.20, rh-7.1) and it's the same. Any help is appreciated. Thank
you.

Regards.
R.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to