sscanf does not rpad zeros?

From: Date: Tue, 07 Nov 2000 02:51:55 +0000
Subject: sscanf does not rpad zeros?
Groups: php.general 
Request: Send a blank email to php-general+get-24044@lists.php.net to get a copy of this message
Greetings. The following bit of code: <?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'. I want the parsed month to be zero padded. Have I missed something? Possibly this is a bug? 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); Thanks Jeff -- jccann [at] home [dot] com

« previous php.general (#24044) next »