RE: [PHP] Need help with formatting time

From: Date: Tue, 17 Jul 2001 20:16:33 +0000
Subject: RE: [PHP] Need help with formatting time
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-58338@lists.php.net to get a copy of this message
Once again, a reminder of the smartest way to code php: 1) think for 2 seconds 2) check out php.net for documentation on functions 3) use a function (or 2) already written instead of spending time yourself... jack -----Original Message----- From: Christopher Ostmo [mailto:tech@appideas.com] Sent: Tuesday, July 17, 2001 5:11 PM To: Jack Dempsey Cc: php-general@lists.php.net Subject: RE: [PHP] Need help with formatting time Jack Dempsey pressed the little lettered thingies in this order... > $hours = $time / 60; > $minutes = $time % 60; > > if($hours >= 12){ > $meridian = 'pm'; > $hours -= 12; > } > else{$meridian = 'am';} > if($hours == 0){$hour = '12';} > > echo "$hours:$minutes$meridian"; > > try something like that...haven't tested it, but it should be close... > That's a lot of code! Use date() and mktime() and PHP will do all of this for you in one line. See my previous post on the subject. I sent *tested* code that will fit on a single line and will do exactly what the above is doing. Christopher Ostmo a.k.a. tech@AppIdeas.com AppIdeas.com Innovative Application Ideas Meeting cutting edge dynamic web site needs since the dawn of Internet time (1995) Business Applications: http://www.AppIdeas.com/ Open Source Applications: http://open.AppIdeas.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 (#58338) next »