Showing posts with label php. Show all posts
Showing posts with label php. Show all posts

Monday, March 29, 2010

Upgrading CentOS 5.4 to PHP 5.2.11

rpm --import http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka
vi /etc/yum.repos.d/utterramblings.repo

Paste into file:
[utterramblings]
name=Jason's Utter Ramblings Repo
baseurl=http://www.jasonlitka.com/media/EL$releasever/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka

yum install php

Wednesday, March 3, 2010

Converting military 24 hour time to 12 hour time in PHP

Here is a function I use with array_walk to convert all of the values in the array to 12 hour time from military time.


function convert_to_twelve_hour(&$i) {
if($i >= 1 && $i <= 12) {
$hour = $i;
$ampm = ($i < 12) ? 'am' : 'pm';
} elseif($i < 1) {
$hour = $i + 12;
$ampm = 'am';
} elseif($i > 12) {
$hour = $i - 12;
$ampm = ($i < 12) ? 'am' : 'pm';
}
$i = $hour.$ampm;
}


This of course is an alternative to:


date("g:i a", strtotime("14:30"));