PHP 4.0 Bug #7705: sscanf does not zero pad decimal

From: Date: Wed, 08 Nov 2000 19:31:56 +0000
Subject: PHP 4.0 Bug #7705: sscanf does not zero pad decimal
Groups: php.dev 
Request: Send a blank email to php-dev+get-37453@lists.php.net to get a copy of this message
From: jccann@home.com Operating system: Windows NT PHP version: 4.0.3 PHP Bug Type: *General Issues Bug description: sscanf does not zero pad decimal <?php $Date = "06/15/2003"; sscanf( $Date, "%02d/%02d/%4d", &$DateMM, &$DateDD, &$DateYYYY ); print "date: $Date<br>"; print "MM: $DateMM<br>"; print "DD: $DateDD<br>"; print "YYYY: $DateYYYY<br>" ?> produces this output: Date: 06/15/2003 MM: 6 DD: 15 YYYY: 2003 Notice that for $DateMM, I specified '%02d", yet the parsed month is '6' and not '06'. According to Example 1 in the PHP manual for sprintf (http://www.php.net/manual/html/function.sprintf.html) the correct format for zero padded integers is: sprintf ("%04d-%02d-%02d", $year, $month, $day); -- Edit Bug report at: http://bugs.php.net/?id=7705&edit=1

« previous php.dev (#37453) next »