Re: Problem with Date Format
| From: | Seth Northrop | Date: | Fri, 05 Jan 2001 08:30:58 +0000 |
| Subject: | Re: Problem with Date Format | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-32849@lists.php.net to get a copy of this message | ||
> I need to retrieve a date which is in the format
> mm/dd/yy from my database and add 1 month to this
> date. I want to display this date as for eg 20 NOVEMBER
> 2000.
If I'm understanding you something like this should work (untested and
from the hip).
# set your DB date to $date then...
# explode the date mm/dd/yy
$junk = explode("/",$date);
# increment month
$month = $junk[0]+1;
# Check for year roll over
if ($month == 13)
{
# set to first month
$month = 1;
# roll year up one
$junk[2] = $junk[2]+1;
}
# Build new date format
$newdate = date("d F Y",mktime(0,0,0,$month,$junk[1],$junk[2]));
see:
explode:
http://www.php.net/explode
date:
http://www.php.net/date
mktime:
http://www.php.net/mktime
Hope this helps.
Seth