RE: [PHP] Need help with formatting time

From: Date: Tue, 17 Jul 2001 20:06:50 +0000
Subject: RE: [PHP] Need help with formatting time
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-58335@lists.php.net to get a copy of this message
This will convert minutes to hours, then convert to 12-hour am|pm based time. all hours have 60 minutes. it's simple mathematics to convert. $m = 780; $h = 0; // convert to hours:minutes while ($m >= 60) { $h++; $m -= 60; } print "$h:$m \n"; // convert to 12-hour am|pm if (!$h) { $suff = "am"; $h = 12; } elseif ($h == 12) { $suff = "pm"; } elseif ($h > 12) { $suff = "pm"; $h -= 12; } print "$h:$m $suff"; > -----Original Message----- > From: John Holcomb [mailto:john_6932php@yahoo.com] > Sent: Tuesday, July 17, 2001 3:53 PM > To: php-general@lists.php.net > Cc: john_6932php@yahoo.com > Subject: [PHP] Need help with formatting time > > > Hello and thank you. > > I'm trying to find a function(method) or existing > code taht takes the number of minutes that have passed > in a day and returns the time of the day. For > example: > > 780 minutes == 1pm, > 0 minutes == 12am, > etc,etc..... > > so I'm looking for code that when you enter the number > of minutes, it returns the time of day. > > example: > > $some_time = foo(780); > > print($some_time); > > //prints 1:00pm > > > Thnaks again. > > __________________________________________________ > Do You Yahoo!? > Get personalized email addresses from Yahoo! Mail > http://personal.mail.yahoo.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 (#58335) next »