Generate formatted number using php -
i want generate formatted number xxx/yy/zz. xxx= unique auto increment number
. yy= current month. zz= current year.
when creating number **012/02/16**
. after number should **013/02/16**
. after new month should automatically showing **001/03/16**
.
so pleas give me instructions develop number thank much
this code
$today_month= date('m'); $pre_month= date("m",strtotime("-1 month")); $today_year= date('y'); if(isset($pre_month)){ $today_month= date('m'); $pre_month= date("m",strtotime("-1 month")); //echo $pre_month; $today_year= date('y'); //$pre_year= date("y",strtotime("-1 year")); //echo $today_year; $a = 1; $last_id= ++$a; $last_id_new= $last_id+1; $invid = str_pad($last_id_new, 3, '0', str_pad_left); $x= $invid; $ref_number = $x."/".$today_month."/".$today_year; //echo $ref_number; } else{ $today_month= date('m'); $pre_month= date("m",strtotime("-1 month")); //echo $pre_month; $today_year= date('y'); //$pre_year= date("y",strtotime("-1 year")); //echo $today_year; $a= 0; $last_id= ++$a; $last_id_new= $last_id+1; $invid = str_pad($last_id_new, 3, '0', str_pad_left); $x= $invid; $ref_number = $x."/".$today_month."/".$today_year; //echo $ref_number; }
Comments
Post a Comment