020 555 1111
  • Old fashion, modular, procedural PHP plus some scaffolding techniques to allow it to mimic MVC simplicity.
  • A quick reference to help you find in PHP maze what needs to be done and how to do it.
  • Learn a PHP Object Oriented Programming by building a live discussion forum application.
  • MVC - Model View Controller - real life, easy reference and application.
This product has options, take a look at them and select ones you like the most.
Options are displayed under image section.

date time format functions
[php functions]

// Return date in raw format
// $date should be in format mm/dd/yyyy
// raw date is in format YYYYMMDD, or DDMMYYYY
function tep_date_raw($date, $reverse = false) {
  if ($reverse) {
    return substr($date, 3, 2) . substr($date, 0, 2) . substr($date, 6, 4);
  } else {
    return substr($date, 6, 4) . substr($date, 0, 2) . substr($date, 3, 2);
  }
}

 

// Output a raw date string in the selected locale date format
// $raw_date needs to be in this format: YYYY-MM-DD HH:MM:SS
function tep_date_long($raw_date) {
	if ( ($raw_date == '0000-00-00 00:00:00') || ($raw_date == '') ) return false;
	
	$year = (int)substr($raw_date, 0, 4);
	$month = (int)substr($raw_date, 5, 2);
	$day = (int)substr($raw_date, 8, 2);
	$hour = (int)substr($raw_date, 11, 2);
	$minute = (int)substr($raw_date, 14, 2);
	$second = (int)substr($raw_date, 17, 2);
	
	return strftime(DATE_FORMAT_LONG, mktime($hour,$minute,$second,$month,$day,$year));
}

 

// Output a raw date string in the selected locale date format
// $raw_date needs to be in this format: YYYY-MM-DD HH:MM:SS
// NOTE: Includes a workaround for dates before 01/01/1970 that fail on windows servers
function tep_date_short($raw_date) {
	if ( ($raw_date == '0000-00-00 00:00:00') || empty($raw_date) ) return false;
	
	$year = substr($raw_date, 0, 4);
	$month = (int)substr($raw_date, 5, 2);
	$day = (int)substr($raw_date, 8, 2);
	$hour = (int)substr($raw_date, 11, 2);
	$minute = (int)substr($raw_date, 14, 2);
	$second = (int)substr($raw_date, 17, 2);
	
	if (@date('Y', mktime($hour, $minute, $second, $month, $day, $year)) == $year) {
	  return date(DATE_FORMAT, mktime($hour, $minute, $second, $month, $day, $year));
	} else {
	  return preg_replace('/2037$/', $year, date(DATE_FORMAT, mktime($hour, $minute, $second, $month, $day, 2037)));
	}
}

 

  function tep_datetime_short($raw_datetime) {
    if ( ($raw_datetime == '0000-00-00 00:00:00') || ($raw_datetime == '') ) return false;

    $year = (int)substr($raw_datetime, 0, 4);
    $month = (int)substr($raw_datetime, 5, 2);
    $day = (int)substr($raw_datetime, 8, 2);
    $hour = (int)substr($raw_datetime, 11, 2);
    $minute = (int)substr($raw_datetime, 14, 2);
    $second = (int)substr($raw_datetime, 17, 2);

    return strftime(DATE_TIME_FORMAT, mktime($hour, $minute, $second, $month, $day, $year));
  }

 

// datetime translate function - output: 16-Aug-2007 11:50:54
  function tep_date_type_a($date) {
    if ( ($date == '0000-00-00 00:00:00') || ($date == '') ) return false;

    $date = explode(' ',$date);
	$dateDay = explode('-',$date[0]);
	$year = (int)$dateDay[0];
    $month = (int)$dateDay[1];
    $day = (int)$dateDay[2];
	$time = explode(':',$date[1]);
    $hour = (int)$time[0];
    $minute = (int)$time[1];
    $second = (int)$time[2];
	
	if 		($month == 1) {$month_fullname = TEXT_JANS;} 
	elseif	($month == 2) {$month_fullname = TEXT_FEBS;}
	elseif	($month == 3) {$month_fullname = TEXT_MARS;}
	elseif	($month == 4) {$month_fullname = TEXT_APRS;}
	elseif	($month == 5) {$month_fullname = TEXT_MAYS;}
	elseif	($month == 6) {$month_fullname = TEXT_JUNS;}
	elseif	($month == 7) {$month_fullname = TEXT_JULS;}
	elseif	($month == 8) {$month_fullname = TEXT_AUGS;}
	elseif	($month == 9) {$month_fullname = TEXT_SEPS;}
	elseif	($month == 10) {$month_fullname = TEXT_OCTS;}
	elseif	($month == 11) {$month_fullname = TEXT_NOVS;}
	elseif	($month == 12) {$month_fullname = TEXT_DECS;}
	
	if ($minute < 10) { $fixed_minute = '0'.$minute;} else { $fixed_minute = $minute; }
	if ($second < 10) { $fixed_second = '0'.$second;} else { $fixed_second = $second; }
	if ($hour < 10) { $fixed_hour = '0'.$hour;} else { $fixed_hour = $hour; }
	
	$ready_date = $day.'-'.$month_fullname.'-'.$year.' '.$fixed_hour.':'.$fixed_minute.':'.$fixed_second;

    return  $ready_date;
  }

 

// datetime translate function - output: 16 Aug, 2007 1:50:54
  function tep_date_type_b($date) {
    if ( ($date == '0000-00-00 00:00:00') || ($date == '') ) return false;

    $date = explode(' ',$date);
	$dateDay = explode('-',$date[0]);
	$year = (int)$dateDay[0];
    $month = (int)$dateDay[1];
    $day = (int)$dateDay[2];
	$time = explode(':',$date[1]);
    $hour = (int)$time[0];
    $minute = (int)$time[1];
    $second = (int)$time[2];
	
	if 		($month == 1) {$month_fullname = TEXT_JANS;} 
	elseif	($month == 2) {$month_fullname = TEXT_FEBS;}
	elseif	($month == 3) {$month_fullname = TEXT_MARS;}
	elseif	($month == 4) {$month_fullname = TEXT_APRS;}
	elseif	($month == 5) {$month_fullname = TEXT_MAYS;}
	elseif	($month == 6) {$month_fullname = TEXT_JUNS;}
	elseif	($month == 7) {$month_fullname = TEXT_JULS;}
	elseif	($month == 8) {$month_fullname = TEXT_AUGS;}
	elseif	($month == 9) {$month_fullname = TEXT_SEPS;}
	elseif	($month == 10) {$month_fullname = TEXT_OCTS;}
	elseif	($month == 11) {$month_fullname = TEXT_NOVS;}
	elseif	($month == 12) {$month_fullname = TEXT_DECS;}
	
	if ($minute < 10) { $fixed_minute = '0'.$minute;} else { $fixed_minute = $minute; }
	if ($second < 10) { $fixed_second = '0'.$second;} else { $fixed_second = $second; }
	
	$ready_date = $day.' '.$month_fullname.', '.$year.' '.$hour.':'.$fixed_minute.':'.$fixed_second;

    return  $ready_date;
  }

 

// datetime translate function - output: 16 August [08], 2007 1:50:54
  function tep_date_type_c($date) {
    if ( ($date == '0000-00-00 00:00:00') || ($date == '') ) return false;

    $date = explode(' ',$date);
	$dateDay = explode('-',$date[0]);
	$year = (int)$dateDay[0];
    $month = (int)$dateDay[1];
    $day = (int)$dateDay[2];
	$time = explode(':',$date[1]);
    $hour = (int)$time[0];
    $minute = (int)$time[1];
    $second = (int)$time[2];
	
	
	if 		($month == 1) {$month_fullname = TEXT_JAN;} 
	elseif	($month == 2) {$month_fullname = TEXT_FEB;}
	elseif	($month == 3) {$month_fullname = TEXT_MAR;}
	elseif	($month == 4) {$month_fullname = TEXT_APR;}
	elseif	($month == 5) {$month_fullname = TEXT_MAY;}
	elseif	($month == 6) {$month_fullname = TEXT_JUN;}
	elseif	($month == 7) {$month_fullname = TEXT_JUL;}
	elseif	($month == 8) {$month_fullname = TEXT_AUG;}
	elseif	($month == 9) {$month_fullname = TEXT_SEP;}
	elseif	($month == 10) {$month_fullname = TEXT_OCT;}
	elseif	($month == 11) {$month_fullname = TEXT_NOV;}
	elseif	($month == 12) {$month_fullname = TEXT_DEC;}
	
	if ($minute < 10) { $fixed_minute = '0'.$minute;} else { $fixed_minute = $minute; }
	if ($second < 10) { $fixed_second = '0'.$second;} else { $fixed_second = $second; }
	
	$mo = $month;
	if (strlen($mo)=='1') $mo = '0'.$month;
	
	$ready_date = $day.' '.$month_fullname.'-'.$mo.', '.$year.' '.$hour.':'.$fixed_minute.':'.$fixed_second;

    return  $ready_date;
  }

 

// datetime translate function - output: 16 August, 2007 1:50:54
  function tep_date_type_d($date) {
    if ( ($date == '0000-00-00 00:00:00') || ($date == '') ) return false;

    $date = explode(' ',$date);
	$dateDay = explode('-',$date[0]);
	$year = (int)$dateDay[0];
    $month = (int)$dateDay[1];
    $day = (int)$dateDay[2];
	$time = explode(':',$date[1]);
    $hour = (int)$time[0];
    $minute = (int)$time[1];
    $second = (int)$time[2];
	
	
	if 		($month == 1) {$month_fullname = TEXT_JAN;} 
	elseif	($month == 2) {$month_fullname = TEXT_FEB;}
	elseif	($month == 3) {$month_fullname = TEXT_MAR;}
	elseif	($month == 4) {$month_fullname = TEXT_APR;}
	elseif	($month == 5) {$month_fullname = TEXT_MAY;}
	elseif	($month == 6) {$month_fullname = TEXT_JUN;}
	elseif	($month == 7) {$month_fullname = TEXT_JUL;}
	elseif	($month == 8) {$month_fullname = TEXT_AUG;}
	elseif	($month == 9) {$month_fullname = TEXT_SEP;}
	elseif	($month == 10) {$month_fullname = TEXT_OCT;}
	elseif	($month == 11) {$month_fullname = TEXT_NOV;}
	elseif	($month == 12) {$month_fullname = TEXT_DEC;}
	
	if ($minute < 10) { $fixed_minute = '0'.$minute;} else { $fixed_minute = $minute; }
	if ($second < 10) { $fixed_second = '0'.$second;} else { $fixed_second = $second; }
	
	$ready_date = $day.' '.$month_fullname.', '.$year.' '.$hour.':'.$fixed_minute.':'.$fixed_second;

    return  $ready_date;
  }

 

// datetime translate function - output: Friday 16 August, 2007 1:50:54
  function tep_date_type_e($date) {
    if ( ($date == '0000-00-00 00:00:00') || ($date == '') ) return false;

    $date = explode(' ',$date);
	$dateDay = explode('-',$date[0]);
	$year = (int)$dateDay[0];
    $month = (int)$dateDay[1];
    $day = (int)$dateDay[2];
	$time = explode(':',$date[1]);
    $hour = (int)$time[0];
    $minute = (int)$time[1];
    $second = (int)$time[2];
	
	
	if 		($month == 1) {$month_fullname = TEXT_JAN;} 
	elseif	($month == 2) {$month_fullname = TEXT_FEB;}
	elseif	($month == 3) {$month_fullname = TEXT_MAR;}
	elseif	($month == 4) {$month_fullname = TEXT_APR;}
	elseif	($month == 5) {$month_fullname = TEXT_MAY;}
	elseif	($month == 6) {$month_fullname = TEXT_JUN;}
	elseif	($month == 7) {$month_fullname = TEXT_JUL;}
	elseif	($month == 8) {$month_fullname = TEXT_AUG;}
	elseif	($month == 9) {$month_fullname = TEXT_SEP;}
	elseif	($month == 10) {$month_fullname = TEXT_OCT;}
	elseif	($month == 11) {$month_fullname = TEXT_NOV;}
	elseif	($month == 12) {$month_fullname = TEXT_DEC;}
	
	if ($minute < 10) { $fixed_minute = '0'.$minute;} else { $fixed_minute = $minute; }
	if ($second < 10) { $fixed_second = '0'.$second;} else { $fixed_second = $second; }
	
	$ready_date = date('l', mktime($hour,$minute,$second,$month,$day,$year)).' '.$day.' '.$month_fullname.', '.$year.' '.$hour.':'.$fixed_minute.':'.$fixed_second;

    return  $ready_date;
  }

 

// datetime translate function - output: 16-Aug-2007
  function tep_date_type_f($date) {
    if ( ($date == '0000-00-00 00:00:00') || ($date == '') ) return false;

    $date = explode(' ',$date);
	$dateDay = explode('-',$date[0]);
	$year = (int)$dateDay[0];
    $month = (int)$dateDay[1];
    $day = (int)$dateDay[2];
	
	if 		($month == 1) {$month_fullname = TEXT_JANS;} 
	elseif	($month == 2) {$month_fullname = TEXT_FEBS;}
	elseif	($month == 3) {$month_fullname = TEXT_MARS;}
	elseif	($month == 4) {$month_fullname = TEXT_APRS;}
	elseif	($month == 5) {$month_fullname = TEXT_MAYS;}
	elseif	($month == 6) {$month_fullname = TEXT_JUNS;}
	elseif	($month == 7) {$month_fullname = TEXT_JULS;}
	elseif	($month == 8) {$month_fullname = TEXT_AUGS;}
	elseif	($month == 9) {$month_fullname = TEXT_SEPS;}
	elseif	($month == 10) {$month_fullname = TEXT_OCTS;}
	elseif	($month == 11) {$month_fullname = TEXT_NOVS;}
	elseif	($month == 12) {$month_fullname = TEXT_DECS;}
	
	if (strlen($day)==1) { $dayx = '0'.$day; } else { $dayx = $day; }
	$ready_date = $dayx.'-'.$month_fullname.'-'.$year;

    return  $ready_date;
  }

 

// datetime translate function - output: 16 Aug 2007
  function tep_date_type_g($date) {
    if ( ($date == '0000-00-00 00:00:00') || ($date == '') ) return false;

    $date = explode(' ',$date);
	$dateDay = explode('-',$date[0]);
	$year = (int)$dateDay[0];
    $month = (int)$dateDay[1];
    $day = (int)$dateDay[2];
	
	if 		($month == 1) {$month_fullname = TEXT_JANS;} 
	elseif	($month == 2) {$month_fullname = TEXT_FEBS;}
	elseif	($month == 3) {$month_fullname = TEXT_MARS;}
	elseif	($month == 4) {$month_fullname = TEXT_APRS;}
	elseif	($month == 5) {$month_fullname = TEXT_MAYS;}
	elseif	($month == 6) {$month_fullname = TEXT_JUNS;}
	elseif	($month == 7) {$month_fullname = TEXT_JULS;}
	elseif	($month == 8) {$month_fullname = TEXT_AUGS;}
	elseif	($month == 9) {$month_fullname = TEXT_SEPS;}
	elseif	($month == 10) {$month_fullname = TEXT_OCTS;}
	elseif	($month == 11) {$month_fullname = TEXT_NOVS;}
	elseif	($month == 12) {$month_fullname = TEXT_DECS;}
	
	if (strlen($day)==1) { $dayx = '0'.$day; } else { $dayx = $day; }
	$ready_date = $dayx.' '.$month_fullname.' '.$year;

    return  $ready_date;
  }

 

// datetime translate function - output: 16 Aug 2007
  function tep_date_type_h($date) {
    if ( ($date == '0000-00-00 00:00:00') || ($date == '') ) return false;

    $date = explode(' ',$date);
	$dateDay = explode('-',$date[0]);
	$year = (int)$dateDay[0];
    $month = (int)$dateDay[1];
    $day = (int)$dateDay[2];
	
	if 		($month == 1) {$month_fullname = TEXT_JANS;} 
	elseif	($month == 2) {$month_fullname = TEXT_FEBS;}
	elseif	($month == 3) {$month_fullname = TEXT_MARS;}
	elseif	($month == 4) {$month_fullname = TEXT_APRS;}
	elseif	($month == 5) {$month_fullname = TEXT_MAYS;}
	elseif	($month == 6) {$month_fullname = TEXT_JUNS;}
	elseif	($month == 7) {$month_fullname = TEXT_JULS;}
	elseif	($month == 8) {$month_fullname = TEXT_AUGS;}
	elseif	($month == 9) {$month_fullname = TEXT_SEPS;}
	elseif	($month == 10) {$month_fullname = TEXT_OCTS;}
	elseif	($month == 11) {$month_fullname = TEXT_NOVS;}
	elseif	($month == 12) {$month_fullname = TEXT_DECS;}
	else {$month_fullname = '';}
	
	if (strlen($day)==1) { $dayx = '0'.$day; } else { $dayx = $day; }
	
	if (tep_not_null($dayx) && ($dayx!='00')) {
		$ready_date = $dayx.' '.$month_fullname.' '.$year;
		} else {
		$ready_date = $month_fullname.' '.$year;
		}

    return  $ready_date;
  }

 

// datetime translate function - output: 16 August 2007
  function tep_date_type_i($date) {
    if ( ($date == '0000-00-00 00:00:00') || ($date == '') ) return false;

    $date = explode(' ',$date);
	$dateDay = explode('-',$date[0]);
	$year = (int)$dateDay[0];
    $month = (int)$dateDay[1];
    $day = (int)$dateDay[2];
	
	if 		($month == 1) {$month_fullname = TEXT_JAN;} 
	elseif	($month == 2) {$month_fullname = TEXT_FEB;}
	elseif	($month == 3) {$month_fullname = TEXT_MAR;}
	elseif	($month == 4) {$month_fullname = TEXT_APR;}
	elseif	($month == 5) {$month_fullname = TEXT_MAY;}
	elseif	($month == 6) {$month_fullname = TEXT_JUN;}
	elseif	($month == 7) {$month_fullname = TEXT_JUL;}
	elseif	($month == 8) {$month_fullname = TEXT_AUG;}
	elseif	($month == 9) {$month_fullname = TEXT_SEP;}
	elseif	($month == 10) {$month_fullname = TEXT_OCT;}
	elseif	($month == 11) {$month_fullname = TEXT_NOV;}
	elseif	($month == 12) {$month_fullname = TEXT_DEC;}
	
	if (strlen($day)==1) { $dayx = '0'.$day; } else { $dayx = $day; }

	if (tep_not_null($dayx) && ($dayx!='00')) {
		$ready_date = $dayx.' '.$month_fullname.' '.$year;
		} else {
		$ready_date = $month_fullname.' '.$year;
		}

    return  $ready_date;
  }

 

//datetime translate function - output: 16 August 2007
  function tep_date_type_j($date) {
    if ( ($date == '0000-00-00 00:00:00') || ($date == '') ) return false;

    $date = explode(' ',$date);
	$dateDay = explode('-',$date[0]);
	$year = (int)$dateDay[0];
    $month = (int)$dateDay[1];
    $day = (int)$dateDay[2];
	
	if 		($month == 1) {$month_fullname = TEXT_JAN;} 
	elseif	($month == 2) {$month_fullname = TEXT_FEB;}
	elseif	($month == 3) {$month_fullname = TEXT_MAR;}
	elseif	($month == 4) {$month_fullname = TEXT_APR;}
	elseif	($month == 5) {$month_fullname = TEXT_MAY;}
	elseif	($month == 6) {$month_fullname = TEXT_JUN;}
	elseif	($month == 7) {$month_fullname = TEXT_JUL;}
	elseif	($month == 8) {$month_fullname = TEXT_AUG;}
	elseif	($month == 9) {$month_fullname = TEXT_SEP;}
	elseif	($month == 10) {$month_fullname = TEXT_OCT;}
	elseif	($month == 11) {$month_fullname = TEXT_NOV;}
	elseif	($month == 12) {$month_fullname = TEXT_DEC;}
	
	if (strlen($day)==1) { $dayx = '0'.$day; } else { $dayx = $day; }
	$ready_date = $dayx.' '.$month_fullname.' '.$year;

    return  $ready_date;
  }

 

//datetime translate function for expiry/start date show - output: August 2007
  function tep_date_type_k($date) {
    if ( ($date == '0000-00-00 00:00:00') || ($date == '') ) return false;

    $date = explode(' ',$date);
	$dateDay = explode('-',$date[0]);
	$year = (int)$dateDay[0];
    $month = (int)$dateDay[1];
	
	if 		($month == 1) {$month_fullname = TEXT_JAN;} 
	elseif	($month == 2) {$month_fullname = TEXT_FEB;}
	elseif	($month == 3) {$month_fullname = TEXT_MAR;}
	elseif	($month == 4) {$month_fullname = TEXT_APR;}
	elseif	($month == 5) {$month_fullname = TEXT_MAY;}
	elseif	($month == 6) {$month_fullname = TEXT_JUN;}
	elseif	($month == 7) {$month_fullname = TEXT_JUL;}
	elseif	($month == 8) {$month_fullname = TEXT_AUG;}
	elseif	($month == 9) {$month_fullname = TEXT_SEP;}
	elseif	($month == 10) {$month_fullname = TEXT_OCT;}
	elseif	($month == 11) {$month_fullname = TEXT_NOV;}
	elseif	($month == 12) {$month_fullname = TEXT_DEC;}
	
	$ready_date = $month_fullname.' '.$year;

    return  $ready_date;
  }

 

// translates, eg. 1106 to mo/yr date - it shows - output: August 2007
  function tep_date_type_l($date) {
    if ( ($date == '0000-00-00 00:00:00') || ($date == '0000-00-00') || ($date == '') ) return false;

    $month = (int)substr($date, 0, 2);
		if ((substr($date, 2, 2)) < 10)  { $prefix = '200'; } else { $prefix = '20'; }
	$year = $prefix.(int)substr($date, 2, 2);
	
	if 		($month == 1) {$month_fullname = TEXT_JAN;} 
	elseif	($month == 2) {$month_fullname = TEXT_FEB;}
	elseif	($month == 3) {$month_fullname = TEXT_MAR;}
	elseif	($month == 4) {$month_fullname = TEXT_APR;}
	elseif	($month == 5) {$month_fullname = TEXT_MAY;}
	elseif	($month == 6) {$month_fullname = TEXT_JUN;}
	elseif	($month == 7) {$month_fullname = TEXT_JUL;}
	elseif	($month == 8) {$month_fullname = TEXT_AUG;}
	elseif	($month == 9) {$month_fullname = TEXT_SEP;}
	elseif	($month == 10) {$month_fullname = TEXT_OCT;}
	elseif	($month == 11) {$month_fullname = TEXT_NOV;}
	elseif	($month == 12) {$month_fullname = TEXT_DEC;}
	
	$ready_date = $month_fullname.' '.$year;

    return  $ready_date;
  }