RE: [PHP-GENERAL] Getting and formating todays date...

From: Date: Fri, 09 Jun 2000 16:36:05 +0000
Subject: RE: [PHP-GENERAL] Getting and formating todays date...
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-1403@lists.php.net to get a copy of this message
I had some Perl code that does what you want. I quickly converted it to PHP (so a not to offend anyone), but I have not tested it. # Convert Unix time to yyyymmdd format function utime_to_ymdint ($utime) { if ($utime) { list($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($utime); $date = sprintf("%d%02d%02d", $year+1900, $mon+1, $mday); }else{ $date = "19700101"; } return $date; } # Convert yyyymmdd format to mm-dd-yy format function ymdint_to_mdydate ($ymdint) { $year = substr($ymdint, 0, 4); $mon = substr($ymdint, 4, 2); $mday = substr($ymdint, 6, 2); $date = sprintf("%d-%d-%d", $mon, $mday, $year); return $date; } # Convert mm-dd-yy format to yyyymmdd format function mdydate_to_ymdint ($mdydate) { list($mon, $mday, $year) = explode('-', $mdydate); $date = sprintf("%d%02d%02d", $year, $mon, $mday); return $date; } > -----Original Message----- > From: Graham Paul Wooden [mailto:graham@tridia.com] > Sent: Friday, June 09, 2000 8:02 AM > To: php-general@lists.php.net > Subject: [PHP-GENERAL] Getting and formating todays date... > > > Hello all, > I know I am close, but maybe a little far .... > > I need a variable to be todays date in format like 20000609. > I also need to set another variable be 30 days from now, hence 20000709. > > I am doing the following: > > <?php > > $todaysdate = mktime (0,0,0,date("m") ,date("d") ,date("Y")); > $thirtydays = mktime (0,0,0,date("m")+1,date("d") ,date("Y")); > > echo strftime ("Todays Date: $todaysdate<br>"); > echo ("Expiration : $thirtydays<br>"); > > ?> > > But it's returning the number of seconds since UNIX epoch (i think...). > Am I missing a function to get it in to the format I need it in? > > Thanks all!! > > -Graham. > graham@tridia.com . > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > >

« previous php.general (#1403) next »