Re: adding leading zeros to a date
- From: Oli Filth <catch@xxxxxxxxxxxxxx>
- Date: Wed, 27 Apr 2005 19:54:20 GMT
ZeldorBlat wrote:
Alternatively:
$InDate = date('Y-m-d', mktime(0, 0, 0, $inmonth, $inday, $inyear));
Slight overkill, don't you think? That's like using a regular expression to append something to a string.
Either the sprintf() methohd is cleaner, or something that is explicitly obvious what's going on, like:
$InDate = ($inyear . "-" . (($inmonth < 10) ? "0" : ""). $inmonth . "-" . (($inday < 10) ? "0" : "") . $inday);
-- Oli .
- References:
- adding leading zeros to a date
- From: John Smith
- Re: adding leading zeros to a date
- From: Andrew @ Rockface
- Re: adding leading zeros to a date
- From: ZeldorBlat
- adding leading zeros to a date
- Prev by Date: Re: Convert RGB image to CMYK
- Next by Date: Re: Page works when Form Action is Get but not Post
- Previous by thread: Re: adding leading zeros to a date
- Next by thread: Page works when Form Action is Get but not Post
- Index(es):
Relevant Pages
|