Hello,
I have dates in my database that I need to edit.
An example one would be "2004-01-19 17:01:00"
In my form I have a text field to edit the date "2004-01-19" (using a pop-up date picker) This is fine.
But for the Hours, Minutes, and Seconds I have a seperate drop-menu to edit each. The problem is that the menus won't select the proper Hour, Minute, or Second if they start with a ZERO, or are double 00's.
This is the code I'm using to try and dynamically select the menu items:
<option value="" <?php if (!(strcmp("", substr($row_rs_edit_log['punch_in'], 14, 2)))) {echo "SELECTED";} ?>>Min</option>
<option value="00" <?php if (!(strcmp(00, substr($row_rs_edit_log['punch_in'], 14, 2)))) {echo "SELECTED";} ?>>00</option>
<option value="01" <?php if (!(strcmp(01, substr($row_rs_edit_log['punch_in'], 14, 2)))) {echo "SELECTED";} ?>>01</option>
This is a piece of code from the "Minutes" menu. As you can see I've used substr() to select the Minutes "01".
So when the menu is viewed, I was expecting the third option above to be Selected [option value="01"]. But for some reason the menu value "01" won't match up with the "01" returned from the date.
Instead the menu defaults to the first option [option value=""]
I believe this happens if any of the Hours, Minutes, or Seconds are between 00 and 09. From this I would think that somewhere the zeros are being removed so they end up not matching the values in my menus.
BUT if I do this, it prints out the 0's so I don't know whats up!:
<?php echo substr($row_rs_edit_log['punch_in'], 14, 2); ?>
Can anyone clue me in to the problem? Thanks!