<?php
$year = date('y'); //gets 2 digits of year, ex, year 2014 as 14
$month = date('m');//gets 2 digits of month, ex, month July as 07
$day = date('d');//gets 2 digits of date, ex, date 07
$random = substr( md5(rand()), 0, 4); //generate 4 digits random number using 0-9 and a-z
$code = $year . $month . $day . $random;
echo $code;
?>