Category Archives: PHP

PHP programming

Split a name into First name and Last name using PHP

/** split a name into the first name and last name * @param input The name eg ‘John Doe’ * @return Array containing firstname and lastname eg array(‘firstname’=>’John’, ‘lastname’=>’Doe’); */ function splitname($input) { $output = array(“firstname”=>””, “lastname”=>””); $space = strpos($input, ” “); if ($space !== false) { $output[‘firstname’] = substr($input,… Read more »

Convert a date and time to UTC

      No Comments on Convert a date and time to UTC

/** Converts a date and time to UTC * /param date The date in the format dd/mm/yyyy * /param time The time in the format HH/mm/ss * /return utc */    function utc($inputDate, $inputTime) { $pieces = explode(“/”, $inputDate); $dateus = $pieces[2].”-“.$pieces[1].”-“.$pieces[0]; $stringtime = “$dateus $inputTime”; return strtotime($stringtime); }