This is a discussion on date() function within the PHP General forums, part of the PHP Programming Forums category; I noticed that if I do something like this: $prevminute = date("i")-1; ..and the current minute happens ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
I noticed that if I do something like this: $prevminute = date("i")-1; ..and the current minute happens to be '05', $prevminute becomes '4' - I lose the padding. How can I ensure that I retain that padding? I suppose a crud solution is to run $prevminute through an if loop to see if it's < 10. But I'm wondering if there's a better way. -- W | It's not a bug - it's an undocumented feature. +-------------------------------------------------------------------- Ashley M. Kirchner <mailto:ashley@pcraft.com> . 303.442.6410 x130 IT Director / SysAdmin / Websmith . 800.441.3873 x130 Photo Craft Imaging . 3550 Arapahoe Ave. #6 http://www.pcraft.com ..... . . . Boulder, CO 80303, U.S.A. |
|
|||
|
$prevminute = sprintf('%02s', date("i")-1); > -----Original Message----- > From: Ashley M. Kirchner [mailto:ashley@pcraft.com] > Sent: Tuesday, November 14, 2006 1:17 PM > To: PHP General List > Subject: [php] date() function > > > I noticed that if I do something like this: > > $prevminute = date("i")-1; > > ..and the current minute happens to be '05', $prevminute becomes '4' > - I lose the padding. How can I ensure that I retain that padding? I > suppose a crud solution is to run $prevminute through an if loop to see > if it's < 10. But I'm wondering if there's a better way. > > -- > W | It's not a bug - it's an undocumented feature. > +-------------------------------------------------------------------- > Ashley M. Kirchner <mailto:ashley@pcraft.com> . 303.442.6410 x130 > IT Director / SysAdmin / Websmith . 800.441.3873 x130 > Photo Craft Imaging . 3550 Arapahoe Ave. #6 > http://www.pcraft.com ..... . . . Boulder, CO 80303, U.S.A. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > |