Why not use the date function? date("g:i a"); Trenton > I need to find the exact time of day using "minutes since midnight". > > What is the easiest and/or better way to do this in php? > > This is how I'm doing it now. > > // $iMinutes is the total number of minutes since midnight/12am > // 0 = midnight/12am > // 1439 = 11:59pm > > $iMinutes = 1230; > > if ($iMinutes < 0 || $iMinutes > 1439) { > $restime = "??:??"; > } else { > $iHour = $iMinutes / 60; > $iMins = ($iMinutes - (60*$iHour)) % 60; > > if ($iHour <= 12) { > $restime .= $iHour . ":"; > } else { > $restime .= $iHour-12 . ":"; > } > > if ($iMins < 10) { > $restime .= "0" . $iMins; > } else { > $restime .= $iMins; > } > if ($iHour < 12) { > $restime .= " a.m."; > } else if ($iHour==12 && $iMins==0) { > $restime .= " noon"; > } else { > $restime .= " pm"; > } > } > > > Thanks, Brent > > > ---------------------------------------------------------------- > This message was sent using IMP, the Internet Messaging Program. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php