Always leading hours in time field

  • Eduard
  • Eduard's Avatar Topic Author
  • Visitor
  • Visitor
26 Jan 2013 11:35 - 26 Jan 2013 11:36 #2948 by Eduard
Always leading hours in time field was created by Eduard
I found that in the time column will indicate hours, though earlier such was not.

According to custom, decided to see how the function "insertTime". And I found it all strange. In fact, it should work right! But the result on the face. If the value of hours = 0, the condition if($tmp[0]) return true o_O
Code:
$tmp = explode(':', $time); if ($tmp[0]) {

I corrected it is more precise condition if($tmp [0] != 0) - so began to work correctly. - Although it's strangemay be due because I have are using PHP 5.4 - and this condition works on another (Such opinion I have decided, because earlier I used PHP 5.2, and time displayed correctly).
Last edit: 26 Jan 2013 11:36 by Eduard.

Please Log in or Create an account to join the conversation.

More
26 Jan 2013 11:51 #2950 by Thomas Hunziker
Indeed. The reason is probably that $tmp[0] holds a string with '00' which is in fact not threated "false".
Code:
if ((int)$tmp[0])
would work as well and is probably more realiable.

Please Log in or Create an account to join the conversation.

Time to create page: 0.091 seconds
Powered by Kunena Forum