I have a page where multiple records are shown. One of the pieces of data shown on each record is the time. This has been added to the database in 2 seperate fields timehr and timemin. the users add the time using 2 drop down list menus. the values of each hour and min do have the required 0 so i have 01,02,03, etc but when the data is added to the database 06 becomes 6, hence my question.
When i echo both timehr and timemin it works fine but when say its 6am in the databse the fields are filled with timehr = 6 and timemin = 0.
I want to add a zero to the left of timehr and to the right of timemin. so all times read 01:30, 06:00 etc and not 1:30, 6:0 etc
I have tried the following:
$s_Time = str_pad($info['timehr'], 2,'0', STR_PAD_LEFT) . ':' . str_pad($info['timemin'], 2, '0', STR_PAD_LEFT);
It doesnt work, instead i get 00:00 for every record regardless of what characters are in the data fields.
I am guessing it has somethiong to do with the numbers not being strings? Therefore it doesnt count any characters and thus gives 00.
Do i need to convert my $info['timehr'] into a string or am i complety barking up the wrong tree?
Can anyone help please?
Thanks in advance!